Python module tensorflow was not found. (Similar to issue #144)

Encounter issue as tittle stated. After refer to issue #144, try all the tricks there, this is my current state.

Version:1.0 StartHTML:0000000107 EndHTML:0000002321 StartFragment:0000000127 EndFragment:0000002303

> library(tensorflow) 
> use_condaenv("r-reticulate") 
> sess <- tf$Session() 

Error: Python module tensorflow was not found. 

Detected Python configuration: 
python: C:\Users\cao_e\Documents\.conda\envs\r-reticulate\python.exe 
libpython: C:/Users/cao_e/Documents/.conda/envs/r-reticulate/python36.dll 
pythonhome: C:\Users\cao_e\DOCUME~1\CONDA~1\envs\R-RETI~1 
version: 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] 
Architecture: 64bit 
numpy: C:\Users\cao_e\DOCUME~1\CONDA~1\envs\R-RETI~1\lib\site-packages\numpy 
numpy_version: 1.17.0 
tensorflow: C:\Users\cao_e\DOCUME~1\CONDA~1\envs\R-RETI~1\lib\site-packages\tensorflow\__init__.p 

python versions found: 
C:\Users\cao_e\Documents\.conda\envs\r-reticulate\python.exe C:\PROGRA~3\ANACON~1\python.exe

What can I do here? Please advise.

Welcome to RStudio Community!

I assume you are referring to Issue #144 on the tensorflow GitHub repository. You don't have any spaces in your username, so your issue must be caused by something else.

Could you please describe how you installed tensorflow? Did you follow the Installation instructions?

devtools::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow()

Also, could you please tell us more about your setup by running the following commands in the R console and copy-pasting the results?

reticulate::conda_version()
sessionInfo()

This is the results of executing the suggested instruction.

> devtools::install_github("rstudio/tensorflow")
Downloading GitHub repo rstudio/tensorflow@master
These packages have more recent versions available.
Which would you like to update?

1: All                                               
2: CRAN packages only                                
3: None                                              
4: reticulate (5be94fe3f... -> 6ec7fca7a...) [GitHub]

Enter one or more numbers, or an empty line to skip updates:
1
reticulate (5be94fe3f... -> 6ec7fca7a...) [GitHub]
Downloading GitHub repo rstudio/reticulate@master
√  checking for file 'C:\Users\cao_e\AppData\Local\Temp\RtmpsFe0l0\remotes3db4394051dc\rstudio-reticulate-6ec7fca/DESCRIPTION' ...
-  preparing 'reticulate': (492ms)
√  checking DESCRIPTION meta-information ... 
-  cleaning src
-  checking for LF line-endings in source and make files and shell scripts (338ms)
-  checking for empty or unneeded directories
-  building 'reticulate_1.13.0-9000.tar.gz'
   
Installing package into β€˜C:/Users/cao_e/Documents/R/win-library/3.6’
(as β€˜lib’ is unspecified)
* installing *source* package 'reticulate' ...
** using staged installation
** libs

*** arch - i386
C:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c event_loop.cpp -o event_loop.o
C:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c libpython.cpp -o libpython.o
C:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c output.cpp -o output.o
C:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c python.cpp -o python.o
C:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c readline.cpp -o readline.o
C:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o reticulate.dll tmp.def RcppExports.o event_loop.o libpython.o output.o python.o readline.o -LC:/PROGRA~1/R/R-36~1.1/bin/i386 -lR
installing to C:/Users/cao_e/Documents/R/win-library/3.6/00LOCK-reticulate/00new/reticulate/libs/i386

*** arch - x64
C:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c event_loop.cpp -o event_loop.o
C:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c libpython.cpp -o libpython.o
C:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c output.cpp -o output.o
C:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c python.cpp -o python.o
C:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG  -I"C:/Users/cao_e/Documents/R/win-library/3.6/Rcpp/include"        -O2 -Wall  -mtune=generic -c readline.cpp -o readline.o
C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o reticulate.dll tmp.def RcppExports.o event_loop.o libpython.o output.o python.o readline.o -LC:/PROGRA~1/R/R-36~1.1/bin/x64 -lR
installing to C:/Users/cao_e/Documents/R/win-library/3.6/00LOCK-reticulate/00new/reticulate/libs/x64
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'reticulate'
    finding HTML links ... done
    array_reshape                           html  
    as.character.python.builtin.bytes       html  
    conda-tools                             html  
    dict                                    html  
    eng_python                              html  
    import                                  html  
    iterate                                 html  
    np_array                                html  
    py                                      html  
    py_available                            html  
    py_call                                 html  
    py_capture_output                       html  
    py_config                               html  
    py_config_error_message                 html  
    py_del_item                             html  
    py_discover_config                      html  
    py_func                                 html  
    py_function_custom_scaffold             html  
    py_function_wrapper                     html  
    py_get_attr                             html  
    py_get_item                             html  
    py_has_attr                             html  
    py_help                                 html  
    py_id                                   html  
    py_install                              html  
    py_is_null_xptr                         html  
    py_iterator                             html  
    py_last_error                           html  
    py_len                                  html  
    py_list_attributes                      html  
    py_main_thread_func                     html  
    py_module_available                     html  
    py_run                                  html  
    py_save_object                          html  
    py_set_attr                             html  
    py_set_item                             html  
    py_set_seed                             html  
    py_str                                  html  
    py_suppress_warnings                    html  
    py_to_r_wrapper                         html  
    py_unicode                              html  
    py_versions_windows                     html  
    r-py-conversion                         html  
    register_class_filter                   html  
    register_help_topics                    html  
    register_module_help_handler            html  
    register_suppress_warnings_handler      html  
    repl_python                             html  
    reticulate                              html  
    source_python                           html  
    tuple                                   html  
    use_python                              html  
    virtualenv-tools                        html  
    with-as-operator                        html  
    with.python.builtin.object              html  
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (reticulate)
√  checking for file 'C:\Users\cao_e\AppData\Local\Temp\RtmpsFe0l0\remotes3db44ed47ef4\rstudio-tensorflow-07d9bd5/DESCRIPTION' ... 
-  preparing 'tensorflow': (350ms)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'tensorflow_1.14.0.9000.tar.gz'
   
Installing package into β€˜C:/Users/cao_e/Documents/R/win-library/3.6’
(as β€˜lib’ is unspecified)
* installing *source* package 'tensorflow' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'tensorflow'
    finding HTML links ... done
    all_dims                                html  
    evaluate                                html  
    export_savedmodel                       html  
    install_tensorflow                      html  
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/install_tensorflow.Rd:44: file link 'conda_install' in package 'reticulate' does not exist and so has been treated as a topic
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/install_tensorflow.Rd:45: file link 'virtualenv_install' in package 'reticulate' does not exist and so has been treated as a topic
    install_tensorflow_extras               html  
    parse_arguments                         html  
    finding level-2 HTML links ... done

    parse_flags                             html  
    reexports                               html  
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/reexports.Rd:29: file link '%as%' in package 'reticulate' does not exist and so has been treated as a topic
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/reexports.Rd:29: file link 'use_virtualenv' in package 'reticulate' does not exist and so has been treated as a topic
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/reexports.Rd:29: file link 'use_condaenv' in package 'reticulate' does not exist and so has been treated as a topic
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/reexports.Rd:31: file link 'flag_numeric' in package 'tfruns' does not exist and so has been treated as a topic
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/reexports.Rd:31: file link 'flag_integer' in package 'tfruns' does not exist and so has been treated as a topic
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/reexports.Rd:31: file link 'flag_string' in package 'tfruns' does not exist and so has been treated as a topic
Rd warning: C:/Users/cao_e/AppData/Local/Temp/RtmpwzD4Vk/R.INSTALL3cc87dea6ba9/tensorflow/man/reexports.Rd:31: file link 'flag_boolean' in package 'tfruns' does not exist and so has been treated as a topic
    shape                                   html  
    sub-.tensorflow.tensor                  html  
    tensorboard                             html  
    tensorflow                              html  
    tf                                      html  
    tf_config                               html  
    tf_extract_opts                         html  
    tf_function                             html  
    tf_gpu_configured                       html  
    tf_probability                          html  
    tfe_enable_eager_execution              html  
    train                                   html  
    train_and_evaluate                      html  
    use_compat                              html  
    use_session_with_seed                   html  
    view_savedmodel                         html  
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (tensorflow)
>

I only see the output from devtools::install_github("rstudio/tensorflow"). It appears that the R package was successfully installed. But what about when you try to install the tensorflow software itself with:

library(tensorflow)
install_tensorflow()

Also, it would be helpful to learn more about your setup by sharing the output from the following commands:

reticulate::conda_version()
sessionInfo()

This is the information captured from the console.


1 Like

Thanks for sharing that information. I did a test installation to simulate a similar setup that you have. I used R 3.6.1 on Windows 10.

  • I installed Anaconda3-2019.07-Windows-x86_64.exe
  • I opened the Anaconda Prompt and updated the conda packages with conda update --all
  • I installed the tensorflow R package from GitHub and installed tensorflow into a conda environment named tf
devtools::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow(envname = "tf")

I was able to run this suggested sample code from the Issue. I received warnings about the numpy version, but it was able to find tensorflow.

> library(tensorflow)
> use_condaenv("tf")
> sess <- tf$Session()
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
WARNING: Logging before flag parsing goes to stderr.
W0813 17:17:31.534146 27008 deprecation_wrapper.py:119] From C:\Users\john\ANACON~1\envs\tf\lib\site-packages\tensorflow\python\util\deprecation_wrapper.py:119: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

2019-08-13 17:17:31.555172: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
> hello <- tf$constant('Hello, TensorFlow!')
> sess$run(hello)
b'Hello, TensorFlow!'

And here is my setup information after running the above. It seems very similar to yours:

> reticulate::conda_version()
[1] "conda 4.7.11"
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tensorflow_1.14.0.9000

loaded via a namespace (and not attached):
 [1] compiler_3.6.1         magrittr_1.5           Matrix_1.2-17         
 [4] tools_3.6.1            whisker_0.3-2          base64enc_0.1-3       
 [7] Rcpp_1.0.2             reticulate_1.13.0-9000 grid_3.6.1            
[10] jsonlite_1.6           tfruns_1.4             lattice_0.20-38       

Have you tried uninstalling and reinstalling Anaconda?

2 Likes

THANK YOU, it works!
Just by following your instruction. Uninstalling and reinstalling Anaconda, conda update --all

1 Like

Great! I'm glad that got it working :grinning:

For the benefit of future readers, could you please mark my post as the solution?

FAQ: How do I mark a solution?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.