Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation problems #510

Closed
Allisterh opened this issue Feb 18, 2022 · 8 comments
Closed

Installation problems #510

Allisterh opened this issue Feb 18, 2022 · 8 comments

Comments

@Allisterh
Copy link

I hope this an issue that easily resolved. I have been trying to get TensorFlow and keras to work on my machine for weeks now (windows 11). I can install both packages easily (btw I have anaconda 4.10.3 and R version 4.1.2 installed). However, whenever I close R and reopen it load the packages and try to use them I get this message:

Error: Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
C:\Users\Alister\anaconda3\python.exe

Python exception encountered:
ModuleNotFoundError: No module named 'tensorflow'

Detailed traceback:
File "C:\Users\Alister\Dropbox\PC (2)\Documents\R\win-library\4.1\reticulate\python\rpytools\loader.py", line 39, in _import_hook
module = _import(

You can install TensorFlow using the install_tensorflow() function.

Please can someone tell me what is happening here is this a reticulate problem or tensorflow problem. Like I said I successfully installed TensorFlow and created a an environment in Anaconda but for the life of me it just wont work.

@t-kalinowski
Copy link
Member

Have you run tensorflow::install_tensorflow() ?

@Allisterh
Copy link
Author

This is my exact install tensorflow installation command.

install_tensorflow(method = "conda",
version = "default", envname = "py_tf",
conda_python_version = "3.9",
extra_packages = c("matplotlib", "numpy"))

@t-kalinowski
Copy link
Member

Many installation issues are resolved by running the following in a fresh R session (you can restart R in Rstudio with Ctrl+Shift+F10) :

# install the development version of packages, in case the
# issue is already fixed but not on CRAN yet.
install.packages("remotes")
remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras")))
reticulate::miniconda_uninstall() # start with a blank slate
reticulate::install_miniconda()
keras::install_keras()

Test to see if installation was successful.

tensorflow::as_tensor("Hello World")

If the above snippet succeeded and you saw something like tf.Tensor(b'Hello World', shape=(), dtype=string), then 🎉, you've successfully installed Tensorflow.

If the above installation failed, please gather some diagnostic info:

reticulate::py_config()
tensorflow::tf_config()
reticulate::import("tensorflow")
reticulate::py_last_error()
sessionInfo()

Please copy and paste the FULL OUTPUT of running all three snippets, and be sure to enclose the output lines with three backticks (```) for monospace formatting.

@Allisterh
Copy link
Author

Thanks so much [it worked like a charm. However, I am still puzzled why the conda version of install kept failing. Nonetheless thanks o much for your kind assistance, really appreciated.

@vmandela99
Copy link

@t-kalinowski hope you are doing great.

Thanks for this solution. I got stuck in the last step.

this error:

`> tensorflow::install_tensorflow()

  • "C:/Users/moubi/AppData/Local/r-miniconda/condabin/conda.bat" "remove" "--yes" "--name" "r-tensorflow" "--all"

Remove all packages in environment C:\Users\moubi\AppData\Local\R-MINI~1\envs\r-tensorflow:

Package Plan

environment location: C:\Users\moubi\AppData\Local\R-MINI~1\envs\r-tensorflow

The following packages will be REMOVED:

bzip2-1.0.8-hcfcfb64_5
ca-certificates-2023.11.17-h56e8100_0
libexpat-2.5.0-h63175ca_1
libffi-3.4.2-h8ffe710_5
libsqlite-3.44.2-hcfcfb64_0
libzlib-1.2.13-hcfcfb64_5
openssl-3.2.0-hcfcfb64_1
pip-23.3.2-pyhd8ed1ab_0
python-3.12.1-h2628c8c_1_cpython
setuptools-69.0.3-pyhd8ed1ab_0
tk-8.6.13-h5226925_1
tzdata-2023d-h0c530f3_0
ucrt-10.0.22621.0-h57928b3_0
vc-14.3-hcf57466_18
vc14_runtime-14.38.33130-h82b7239_18
vs2015_runtime-14.38.33130-hcb4865c_18
wheel-0.42.0-pyhd8ed1ab_0
xz-5.2.6-h8d14728_0

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done

  • "C:/Users/moubi/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--name" "r-tensorflow" "python" "--quiet" "-c" "conda-forge"
    Channels:
  • conda-forge
  • defaults
    Platform: win-64
    Collecting package metadata (repodata.json): ...working... done
    Solving environment: ...working... done

Package Plan

environment location: C:\Users\moubi\AppData\Local\R-MINI~1\envs\r-tensorflow

added / updated specs:
- python

The following NEW packages will be INSTALLED:

bzip2 conda-forge/win-64::bzip2-1.0.8-hcfcfb64_5
ca-certificates conda-forge/win-64::ca-certificates-2023.11.17-h56e8100_0
libexpat conda-forge/win-64::libexpat-2.5.0-h63175ca_1
libffi conda-forge/win-64::libffi-3.4.2-h8ffe710_5
libsqlite conda-forge/win-64::libsqlite-3.44.2-hcfcfb64_0
libzlib conda-forge/win-64::libzlib-1.2.13-hcfcfb64_5
openssl conda-forge/win-64::openssl-3.2.0-hcfcfb64_1
pip conda-forge/noarch::pip-23.3.2-pyhd8ed1ab_0
python conda-forge/win-64::python-3.12.1-h2628c8c_1_cpython
setuptools conda-forge/noarch::setuptools-69.0.3-pyhd8ed1ab_0
tk conda-forge/win-64::tk-8.6.13-h5226925_1
tzdata conda-forge/noarch::tzdata-2023d-h0c530f3_0
ucrt conda-forge/win-64::ucrt-10.0.22621.0-h57928b3_0
vc conda-forge/win-64::vc-14.3-hcf57466_18
vc14_runtime conda-forge/win-64::vc14_runtime-14.38.33130-h82b7239_18
vs2015_runtime conda-forge/win-64::vs2015_runtime-14.38.33130-hcb4865c_18
wheel conda-forge/noarch::wheel-0.42.0-pyhd8ed1ab_0
xz conda-forge/win-64::xz-5.2.6-h8d14728_0

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done

C:\Users\moubi\Documents\s.sudan_conflict_vs_soghum_yield\new_project>CALL "C:\Users\moubi\AppData\Local\r-miniconda\condabin\activate.bat" "r-tensorflow"

C:\Users\moubi\Documents\s.sudan_conflict_vs_soghum_yield\new_project>conda.bat activate "r-tensorflow"

(r-tensorflow) C:\Users\moubi\Documents\s.sudan_conflict_vs_soghum_yield\new_project>"C:\Users\moubi\AppData\Local\r-miniconda\envs\r-tensorflow/python.exe" -m pip install --upgrade --no-user "tensorflow==2.14."
ERROR: Could not find a version that satisfies the requirement tensorflow==2.14.
(from versions: none)
ERROR: No matching distribution found for tensorflow==2.14.*
Error: Error installing package(s): ""tensorflow==2.14.*""
In addition: Warning message:
In shell(fi, intern = intern) :
'C:\Users\moubi\AppData\Local\Temp\Rtmp0mton7\file23e8fc23aca.bat' execution failed with error code 1`

@t-kalinowski
Copy link
Member

Hi @Allisterh We no longer recommend using miniconda as the default installation path for TensorFlow.

We recommend installing Python normally, either from www.python.org, or by running reticulate::install_python(), and then running install_tensorflow().

E.g., this should work:

reticulate::install_python()
keras::install_keras()

@Allisterh
Copy link
Author

Hi @Allisterh We no longer recommend using miniconda as the default installation path for TensorFlow.

We recommend installing Python normally, either from www.python.org, or by running reticulate::install_python(), and then running install_tensorflow().

E.g., this should work:

reticulate::install_python()
keras::install_keras()

Does it matter which version of Python you install?

@t-kalinowski
Copy link
Member

t-kalinowski commented Jan 29, 2024

Being on the latest Python version is generally not advisable, ~2 minor versions behind the current Python minor release version is generally the sweet spot for deep learning packages. (3.9.* or 3.10.* today). The default argument to install_python() is "3.9:latest" today, and is generally incremented in new releases when appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants