title: Cannot install Tensorflow in R, "could not find a Python environment for {PATH}"
body: <p>I'm trying to install Tensorflow's GPU acceleration for R onto my PC. I once used the Intel distro for Python which includes the commonly used scientific libraries and I never really used it as I am an R user but it somehow permanently destroyed my computer's ability to have a functioning copy of Python, as in I cannot for some reason properly install libraries. I have Python on my PC right now but I'm not sure if it works or not as it's my one millionth reinstallation of it.</p>
  <p>That aside, I am trying to install Keras for R and I'm encountering some issues.</p>
  <p>When I run:</p>
  <pre><code>&gt; library(tensorflow)
  &gt; install_tensorflow(version = &quot;gpu&quot;)
  </code></pre>
  <p>I get the following error:</p>
  <pre><code>Error: could not find a Python environment for C:\Users\{my name}\AppData\Local\Programs\Python\Python39\python.exe
  </code></pre>
  <p>I checked that directory and <code>python.exe</code> indeed exists, so I'm not sure what's the problem. I'm worried I have haphazardly destroyed some low-level files in a way that prevents me from ever using Python on my installation of Windows ever again. Uninstalling and reinstalling Python doesn't work.</p>
  <p>Do you have any recommendations?</p>
  <p>EDIT: Following the user installation page:</p>
  <pre><code>&gt; library(tensorflow)
  &gt; tf$constant(&quot;Hellow Tensorflow&quot;)
  Error: Python module tensorflow was not found.
  
  Detected Python configuration:
  
  python:         C:/Users/artas/AppData/Local/Programs/Python/Python39/python.exe
  libpython:      C:/Users/artas/AppData/Local/Programs/Python/Python39/python39.dll
  pythonhome:     C:/Users/artas/AppData/Local/Programs/Python/Python39
  version:        3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
  Architecture:   64bit
  numpy:           [NOT FOUND]
  tensorflow:     [NOT FOUND]
  
  NOTE: Python version was forced by use_python function
  </code></pre>
  <p>EDIT 2: I followed @jwarz's advice but now I get this error:</p>
  <pre><code>&gt; tensorflow::install_tensorflow(version = &quot;gpu&quot;)
  Error: .onLoad failed in loadNamespace() for 'tensorflow', details:
    call: py_module_import(module, convert = convert)
    error: ModuleNotFoundError: No module named 'tensorflow'
  
  Detailed traceback: 
    File &quot;C:\Users\artas\Documents\R\win-library\4.0\reticulate\python\rpytools\loader.py&quot;, line 19, in _import_hook
      module = _import(
    File &quot;C:\Users\artas\Documents\R\win-library\4.0\reticulate\python\rpytools\loader.py&quot;, line 19, in _import_hook
      module = _import(
  </code></pre>
  <p>I took the extra step of installing Keras into the conda environment.</p>
  <pre><code>
  &gt; reticulate::conda_install(packages = &quot;tensorflow&quot;)
  Collecting package metadata (current_repodata.json): ...working... done
  Solving environment: ...working... done
  
  ## Package Plan ##
  
    environment location: C:\Users\artas\MINICO~1\envs\r-reticulate
  
    added / updated specs:
      - python
      - tensorflow
  
  
  The following packages will be downloaded:
  
      package                    |            build
      ---------------------------|-----------------
      absl-py-0.11.0             |   py37h03978a9_0         169 KB  conda-forge
      astor-0.8.1                |     pyh9f0ad1d_0          25 KB  conda-forge
      ca-certificates-2020.12.5  |       h5b45459_0         173 KB  conda-forge
      cached-property-1.5.1      |             py_0          10 KB  conda-forge
      certifi-2020.12.5          |   py37h03978a9_0         143 KB  conda-forge
      gast-0.4.0                 |     pyh9f0ad1d_0          12 KB  conda-forge
      google-pasta-0.2.0         |     pyh8c360ce_0          42 KB  conda-forge
      grpcio-1.34.0              |   py37h04d2302_0         1.8 MB  conda-forge
      h5py-3.1.0                 |nompi_py37h19fda09_100        1009 KB  conda-forge
      hdf5-1.10.6                |nompi_he0bbb20_101        19.4 MB  conda-forge
      importlib-metadata-3.3.0   |   py37h03978a9_2          21 KB  conda-forge
      intel-openmp-2020.3        |     h57928b3_311         2.0 MB  conda-forge
      keras-applications-1.0.8   |             py_1          30 KB  conda-forge
      keras-preprocessing-1.1.0  |             py_0          33 KB  conda-forge
      libblas-3.9.0              |            5_mkl         3.9 MB  conda-forge
      libcblas-3.9.0             |            5_mkl         3.9 MB  conda-forge
      liblapack-3.9.0            |            5_mkl         3.9 MB  conda-forge
      libprotobuf-3.14.0         |       h7755175_0         2.3 MB  conda-forge
      m2w64-gcc-libgfortran-5.3.0|                6         342 KB  conda-forge
      m2w64-gcc-libs-5.3.0       |                7         520 KB  conda-forge
      m2w64-gcc-libs-core-5.3.0  |                7         214 KB  conda-forge
      m2w64-gmp-6.1.0            |                2         726 KB  conda-forge
      m2w64-libwinpthread-git-5.0.0.4634.697f757|                2          31 KB  conda-forge
      markdown-3.3.3             |     pyh9f0ad1d_0          66 KB  conda-forge
      mkl-2020.4                 |     hb70f87d_311       172.4 MB  conda-forge
      msys2-conda-epoch-20160418 |                1           3 KB  conda-forge
      numpy-1.19.4               |   py37hd20adf4_1         4.8 MB  conda-forge
      openssl-1.1.1i             |       h8ffe710_0         5.8 MB  conda-forge
      protobuf-3.14.0            |   py37hf2a7229_0         261 KB  conda-forge
      pyreadline-2.1             |py37hc8dfbb8_1002         146 KB  conda-forge
      python-3.7.9               |h7840368_0_cpython        17.9 MB  conda-forge
      python_abi-3.7             |          1_cp37m           4 KB  conda-forge
      scipy-1.6.0                |   py37h6db1a17_0        23.2 MB  conda-forge
      setuptools-49.6.0          |   py37hf50a25e_2         919 KB  conda-forge
      six-1.15.0                 |     pyh9f0ad1d_0          14 KB  conda-forge
      tensorboard-1.14.0         |           py37_0         3.2 MB  conda-forge
      tensorflow-1.14.0          |       h1f41ff6_0          23 KB  conda-forge
      tensorflow-base-1.14.0     |   py37hc8dfbb8_0        57.3 MB  conda-forge
      tensorflow-estimator-1.14.0|   py37h5ca1d4c_0         646 KB  conda-forge
      termcolor-1.1.0            |             py_2           6 KB  conda-forge
      typing_extensions-3.7.4.3  |             py_0          25 KB  conda-forge
      werkzeug-1.0.1             |     pyh9f0ad1d_0         239 KB  conda-forge
      wincertstore-0.2           |py37hc8dfbb8_1005          15 KB  conda-forge
      wrapt-1.12.1               |   py37hcc03f2d_2          46 KB  conda-forge
      zipp-3.4.0                 |             py_0          11 KB  conda-forge
      zlib-1.2.11.1              |   vc14ha0a531f_3         378 KB  intel
      ------------------------------------------------------------
                                             Total:       327.8 MB
  
  The following NEW packages will be INSTALLED:
  
    absl-py            conda-forge/win-64::absl-py-0.11.0-py37h03978a9_0
    astor              conda-forge/noarch::astor-0.8.1-pyh9f0ad1d_0
    ca-certificates    conda-forge/win-64::ca-certificates-2020.12.5-h5b45459_0
    cached-property    conda-forge/noarch::cached-property-1.5.1-py_0
    gast               conda-forge/noarch::gast-0.4.0-pyh9f0ad1d_0
    google-pasta       conda-forge/noarch::google-pasta-0.2.0-pyh8c360ce_0
    grpcio             conda-forge/win-64::grpcio-1.34.0-py37h04d2302_0
    h5py               conda-forge/win-64::h5py-3.1.0-nompi_py37h19fda09_100
    hdf5               conda-forge/win-64::hdf5-1.10.6-nompi_he0bbb20_101
    importlib-metadata conda-forge/win-64::importlib-metadata-3.3.0-py37h03978a9_2
    intel-openmp       conda-forge/win-64::intel-openmp-2020.3-h57928b3_311
    keras-applications conda-forge/noarch::keras-applications-1.0.8-py_1
    keras-preprocessi~ conda-forge/noarch::keras-preprocessing-1.1.0-py_0
    libblas            conda-forge/win-64::libblas-3.9.0-5_mkl
    libcblas           conda-forge/win-64::libcblas-3.9.0-5_mkl
    liblapack          conda-forge/win-64::liblapack-3.9.0-5_mkl
    libprotobuf        conda-forge/win-64::libprotobuf-3.14.0-h7755175_0
    m2w64-gcc-libgfor~ conda-forge/win-64::m2w64-gcc-libgfortran-5.3.0-6
    m2w64-gcc-libs     conda-forge/win-64::m2w64-gcc-libs-5.3.0-7
    m2w64-gcc-libs-co~ conda-forge/win-64::m2w64-gcc-libs-core-5.3.0-7
    m2w64-gmp          conda-forge/win-64::m2w64-gmp-6.1.0-2
    m2w64-libwinpthre~ conda-forge/win-64::m2w64-libwinpthread-git-5.0.0.4634.697f757-2
    markdown           conda-forge/noarch::markdown-3.3.3-pyh9f0ad1d_0
    mkl                conda-forge/win-64::mkl-2020.4-hb70f87d_311
    msys2-conda-epoch  conda-forge/win-64::msys2-conda-epoch-20160418-1
    numpy              conda-forge/win-64::numpy-1.19.4-py37hd20adf4_1
    protobuf           conda-forge/win-64::protobuf-3.14.0-py37hf2a7229_0
    pyreadline         conda-forge/win-64::pyreadline-2.1-py37hc8dfbb8_1002
    scipy              conda-forge/win-64::scipy-1.6.0-py37h6db1a17_0
    six                conda-forge/noarch::six-1.15.0-pyh9f0ad1d_0
    tensorboard        conda-forge/win-64::tensorboard-1.14.0-py37_0
    tensorflow         conda-forge/win-64::tensorflow-1.14.0-h1f41ff6_0
    tensorflow-base    conda-forge/win-64::tensorflow-base-1.14.0-py37hc8dfbb8_0
    tensorflow-estima~ conda-forge/win-64::tensorflow-estimator-1.14.0-py37h5ca1d4c_0
    termcolor          conda-forge/noarch::termcolor-1.1.0-py_2
    typing_extensions  conda-forge/noarch::typing_extensions-3.7.4.3-py_0
    werkzeug           conda-forge/noarch::werkzeug-1.0.1-pyh9f0ad1d_0
    wrapt              conda-forge/win-64::wrapt-1.12.1-py37hcc03f2d_2
    zipp               conda-forge/noarch::zipp-3.4.0-py_0
    zlib               intel/win-64::zlib-1.2.11.1-vc14ha0a531f_3
  
  The following packages will be UPDATED:
  
    openssl              intel::openssl-1.1.1h-vc14he774522_0 --&gt; conda-forge::openssl-1.1.1i-h8ffe710_0
  
  The following packages will be DOWNGRADED:
  
    certifi                          2020.12.5-py39hcbf5309_0 --&gt; 2020.12.5-py37h03978a9_0
    python                           3.9.1-h7840368_1_cpython --&gt; 3.7.9-h7840368_0_cpython
    python_abi                                     3.9-1_cp39 --&gt; 3.7-1_cp37m
    setuptools                          49.6.0-py39h467e6f4_2 --&gt; 49.6.0-py37hf50a25e_2
    wincertstore                        0.2-py39hde42818_1005 --&gt; 0.2-py37hc8dfbb8_1005
  
  
  
  Downloading and Extracting Packages
  liblapack-3.9.0      | 3.9 MB    | ########## | 100% 
  m2w64-gcc-libs-core- | 214 KB    | ########## | 100% 
  typing_extensions-3. | 25 KB     | ########## | 100% 
  six-1.15.0           | 14 KB     | ########## | 100% 
  zipp-3.4.0           | 11 KB     | ########## | 100% 
  gast-0.4.0           | 12 KB     | ########## | 100% 
  openssl-1.1.1i       | 5.8 MB    | ########## | 100% 
  importlib-metadata-3 | 21 KB     | ########## | 100% 
  grpcio-1.34.0        | 1.8 MB    | ########## | 100% 
  absl-py-0.11.0       | 169 KB    | ########## | 100% 
  ca-certificates-2020 | 173 KB    | ########## | 100% 
  tensorflow-1.14.0    | 23 KB     | ########## | 100% 
  tensorflow-estimator | 646 KB    | ########## | 100% 
  intel-openmp-2020.3  | 2.0 MB    | ########## | 100% 
  m2w64-libwinpthread- | 31 KB     | ########## | 100% 
  werkzeug-1.0.1       | 239 KB    | ########## | 100% 
  libcblas-3.9.0       | 3.9 MB    | ########## | 100% 
  h5py-3.1.0           | 1009 KB   | ########## | 100% 
  keras-applications-1 | 30 KB     | ########## | 100% 
  hdf5-1.10.6          | 19.4 MB   | ########## | 100% 
  wincertstore-0.2     | 15 KB     | ########## | 100% 
  msys2-conda-epoch-20 | 3 KB      | ########## | 100% 
  astor-0.8.1          | 25 KB     | ########## | 100% 
  tensorflow-base-1.14 | 57.3 MB   | ########## | 100% 
  python-3.7.9         | 17.9 MB   | ########## | 100% 
  python_abi-3.7       | 4 KB      | ########## | 100% 
  m2w64-gcc-libgfortra | 342 KB    | ########## | 100% 
  tensorboard-1.14.0   | 3.2 MB    | ########## | 100% 
  numpy-1.19.4         | 4.8 MB    | ########## | 100% 
  cached-property-1.5. | 10 KB     | ########## | 100% 
  zlib-1.2.11.1        | 378 KB    | ########## | 100% 
  scipy-1.6.0          | 23.2 MB   | ########## | 100% 
  protobuf-3.14.0      | 261 KB    | ########## | 100% 
  libprotobuf-3.14.0   | 2.3 MB    | ########## | 100% 
  m2w64-gmp-6.1.0      | 726 KB    | ########## | 100% 
  mkl-2020.4           | 172.4 MB  | ########## | 100% 
  wrapt-1.12.1         | 46 KB     | ########## | 100% 
  libblas-3.9.0        | 3.9 MB    | ########## | 100% 
  termcolor-1.1.0      | 6 KB      | ########## | 100% 
  markdown-3.3.3       | 66 KB     | ########## | 100% 
  keras-preprocessing- | 33 KB     | ########## | 100% 
  setuptools-49.6.0    | 919 KB    | ########## | 100% 
  google-pasta-0.2.0   | 42 KB     | ########## | 100% 
  certifi-2020.12.5    | 143 KB    | ########## | 100% 
  m2w64-gcc-libs-5.3.0 | 520 KB    | ########## | 100% 
  pyreadline-2.1       | 146 KB    | ########## | 100% 
  Preparing transaction: ...working... done
  Verifying transaction: ...working... done
  Executing transaction: ...working... done
  </code></pre>
  <p>The installation was successful but I am still getting the above error.</p>