rstudio / tfprobability

R interface to TensorFlow Probability
https://rstudio.github.io/tfprobability/
Other
54 stars 16 forks source link

No module named 'tensorflow_probability' #155

Open TomasVrzal opened 2 years ago

TomasVrzal commented 2 years ago

I tried to install tfprobability package, however, after installation and typing library(tfprobability) the following error occurred:

Error: package or namespace load failed for ‘tfprobability’: .onLoad failed in loadNamespace() for 'tfprobability', details: call: py_module_import(module, convert = convert) error: ModuleNotFoundError: No module named 'tensorflow_probability'

Detailed traceback: File "C:\Users\ibis\Documents\R\win-library\4.0\reticulate\python\rpytools\loader.py", line 44, in _import_hook level=level

I also tried the next step: tfprobability::install_tfprobability() But the same error occurred.

Can someone help me with this issue, please?

t-kalinowski commented 2 years ago

Hello, thanks for filing.

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()
tfprobability::install_tfprobability()

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 :tada:, 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.

TomasVrzal commented 2 years ago

Originally, the first snippet does not help. However, the output indicated that Rtools is not installed and that Rcpp, jsonlite, and reticulate packages can not be successfully installed since the former installation is in the library folder. Therefore, I installed Rtools and removed the packages. Then I tried to run the first snippet of code - without any error.

The output of the second snippet: tf.Tensor(b'Hello World', shape=(), dtype=string)

It looks that it works already.

Thank you very much for your help.