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

Evaluation error: ModuleNotFoundError: No module named 'rpytools' #561

Closed
davidkeras opened this issue Oct 9, 2018 · 7 comments
Closed

Comments

@davidkeras
Copy link

Hi,

I encountered an "ModuleNotFoundError: No module named 'rpytools'" evaluation error when trying to run Keras in R. I have Python 3.7.0 (Anaconda3 5.3.0 64-bit), R version 3.5.1 and RStudio Desktop installed.

To install Keras in R, I have executed the following three lines of R codes.
install.packages("keras")
library(keras)
install_keras()

And after trying to access keras_model_sequential(), I am seeing the "No module named 'rpytools'" error as printed below:

library(keras)
model <- keras_model_sequential()
Error: Evaluation error: ModuleNotFoundError: No module named 'rpytools'.

Interestingly however, if I rerun the keras_model_sequential() again and assign it to model2, it does not display any error, however calling the summary(model2) function then invokes the following same rpytools error again as printed below:

model2 <- keras_model_sequential()
summary(model2)
Error in py_call_impl(callable, dots$args, dots$keywords) :
Evaluation error: ModuleNotFoundError: No module named 'rpytools'.

Appreciate if someone could shed some light on this issue. Thanks in advance for any help you can offer.

@skeydan
Copy link

skeydan commented Oct 9, 2018

Hi, what OS do you have? This is something that seems to occur on (some) Windows machines (sometimes) ...
In any case, to my knowledge TensorFlow does not support Python 3.7 as yet, so I'd better go with 3.6 for now...

@davidkeras
Copy link
Author

Hi,

Thanks for the feedback. I am using Windows 10 machine. Will give it a try on Python 3.6 and see if it makes a difference. Thanks again.

@davidkeras
Copy link
Author

Hi,

I have just tried Python 3.6.5 (Anaconda3 5.2.0 64-bit) but still observing the same rpytools error as shown below.

library(keras)
model <- keras_model_sequential()
Error: Evaluation error: ModuleNotFoundError: No module named 'rpytools'.
model2 <- keras_model_sequential()
summary(model2)
Error in py_call_impl(callable, dots$args, dots$keywords) :
Evaluation error: ModuleNotFoundError: No module named 'rpytools'.

I notice that while running install_keras(), there are two SafetyError messages generated as printed below. Could these SafetyErrors be the source of the issue?

SafetyError: The package for setuptools located at C:\Users\userid\AppData\Local\conda\conda\pkgs\setuptools-40.4.3-py36_0
appears to be corrupted. The path 'Scripts/easy_install.exe'
has a sha256 mismatch.
reported sha256: 993203a406e04936a07829b1f482fd27d739b640482e213f4c49ea1ee78a5fcf
actual sha256: 2a39d1f5dc1e7abd1044e2d950feb4caa309ca3190e53fc83876b31ff2807cca

SafetyError: The package for wheel located at C:\Users\userid\AppData\Local\conda\conda\pkgs\wheel-0.32.0-py36_0
appears to be corrupted. The path 'Scripts/wheel.exe'
has a sha256 mismatch.
reported sha256: 993203a406e04936a07829b1f482fd27d739b640482e213f4c49ea1ee78a5fcf
actual sha256: 876d02f4fd03d4ffd6504c928cff1e682a0a484c01c4bb4b0aa9ebf8b02ff12e

Anyway, I have printed out all the messages generated while running the install_keras() for ease of debug if it is helpful as below. Appreciate your help in this and let me know if there are any other things that you may need.

install_keras()
Creating r-tensorflow conda environment for TensorFlow installation...
Solving environment: ...working... done

==> WARNING: A newer version of conda exists. <==
current version: 4.5.4
latest version: 4.5.11

Please update conda by running

$ conda update -n base conda

Package Plan

environment location: C:\Users\userid\AppData\Local\CONTIN2\ANACON1\envs\r-tensorflow

added / updated specs:
- python=3.6

The following NEW packages will be INSTALLED:

certifi:        2018.8.24-py36_1      
pip:            10.0.1-py36_0         
python:         3.6.6-hea74fb7_0      
setuptools:     40.4.3-py36_0         
vc:             14.1-h0510ff6_4       
vs2015_runtime: 14.15.26706-h3a45250_0
wheel:          0.32.0-py36_0         
wincertstore:   0.2-py36h7fe50ca_0    

Preparing transaction: ...working... done
Verifying transaction: ...working...
SafetyError: The package for setuptools located at C:\Users\userid\AppData\Local\conda\conda\pkgs\setuptools-40.4.3-py36_0
appears to be corrupted. The path 'Scripts/easy_install.exe'
has a sha256 mismatch.
reported sha256: 993203a406e04936a07829b1f482fd27d739b640482e213f4c49ea1ee78a5fcf
actual sha256: 2a39d1f5dc1e7abd1044e2d950feb4caa309ca3190e53fc83876b31ff2807cca

SafetyError: The package for wheel located at C:\Users\userid\AppData\Local\conda\conda\pkgs\wheel-0.32.0-py36_0
appears to be corrupted. The path 'Scripts/wheel.exe'
has a sha256 mismatch.
reported sha256: 993203a406e04936a07829b1f482fd27d739b640482e213f4c49ea1ee78a5fcf
actual sha256: 876d02f4fd03d4ffd6504c928cff1e682a0a484c01c4bb4b0aa9ebf8b02ff12e

done
Executing transaction: ...working... done

To activate this environment, use:

> activate r-tensorflow

To deactivate an active environment, use:

> deactivate

* for power-users using bash, you must source

Solving environment: ...working... done

==> WARNING: A newer version of conda exists. <==
current version: 4.5.4
latest version: 4.5.11

Please update conda by running

$ conda update -n base conda

Package Plan

environment location: C:\Users\userid\AppData\Local\CONTIN2\ANACON1\envs\r-tensorflow

added / updated specs:
- h5py
- keras
- pillow
- pyyaml
- requests
- scipy
- tensorflow
- tensorflow-hub

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
protobuf-3.6.1             |py36he025d50_1001         515 KB  conda-forge

The following NEW packages will be INSTALLED:

absl-py:              0.5.0-py_0               conda-forge
asn1crypto:           0.24.0-py36_1003         conda-forge
astor:                0.7.1-py_0               conda-forge
blas:                 1.0-mkl                             
ca-certificates:      2018.8.24-ha4d7672_0     conda-forge
cffi:                 1.11.5-py36hfa6e2cd_1001 conda-forge
chardet:              3.0.4-py36_1003          conda-forge
cryptography:         2.3.1-py36h74b6da3_0     conda-forge
cryptography-vectors: 2.3.1-py36_1000          conda-forge
freetype:             2.9.1-he8b6a0d_1004      conda-forge
gast:                 0.2.0-py_0               conda-forge
grpcio:               1.14.1-py36he089993_0    conda-forge
h5py:                 2.8.0-py36h54c06b0_3     conda-forge
hdf5:                 1.10.2-vc14_0            conda-forge [vc14]
icc_rt:               2017.0.4-h97af966_0                 
idna:                 2.7-py36_1002            conda-forge
intel-openmp:         2019.0-118                          
jpeg:                 9c-hfa6e2cd_1001         conda-forge
keras:                2.2.4-py36_0             conda-forge
keras-applications:   1.0.4-py_1               conda-forge
keras-preprocessing:  1.0.2-py_1               conda-forge
libgpuarray:          0.7.6-vc14_0             conda-forge [vc14]
libpng:               1.6.34-vc14_0            conda-forge [vc14]
libprotobuf:          3.6.1-h1a1b453_1000      conda-forge
libtiff:              4.0.9-vc14_0             conda-forge [vc14]
mako:                 1.0.7-py_1               conda-forge
markdown:             2.6.11-py_0              conda-forge
markupsafe:           1.0-py36hfa6e2cd_1001    conda-forge
mkl:                  2019.0-118                          
mkl_fft:              1.0.6-py36_0             conda-forge
mkl_random:           1.0.1-py36_0             conda-forge
numpy:                1.15.2-py36ha559c80_0               
numpy-base:           1.15.2-py36h8128ebf_0               
olefile:              0.46-py_0                conda-forge
openssl:              1.0.2o-vc14_0            conda-forge [vc14]
pillow:               5.3.0-py36h9a613e6_1000  conda-forge
protobuf:             3.6.1-py36he025d50_1001  conda-forge
pycparser:            2.19-py_0                conda-forge
pygpu:                0.7.6-py36_0             conda-forge
pyopenssl:            18.0.0-py36_0            conda-forge
pyreadline:           2.1-py36_1000            conda-forge
pysocks:              1.6.8-py36_1002          conda-forge
pyyaml:               3.13-py36hfa6e2cd_1001   conda-forge
requests:             2.19.1-py36_1            conda-forge
scipy:                1.1.0-py36h4f6bf74_1                
six:                  1.11.0-py36_1001         conda-forge
tensorboard:          1.10.0-py36_0            conda-forge
tensorflow:           1.10.0-py36_0            conda-forge
tensorflow-hub:       0.1.1-py_0               conda-forge
termcolor:            1.1.0-py_2               conda-forge
theano:               1.0.3-py36_0             conda-forge
tk:                   8.6.8-vc14_0             conda-forge [vc14]
urllib3:              1.23-py36_1              conda-forge
werkzeug:             0.14.1-py_0              conda-forge
win_inet_pton:        1.0.1-py36_1002          conda-forge
yaml:                 0.1.7-vc14_0             conda-forge [vc14]
zlib:                 1.2.11-vc14_0            conda-forge [vc14]

The following packages will be UPDATED:

certifi:              2018.8.24-py36_1                     --> 2018.8.24-py36_1001 conda-forge

The following packages will be DOWNGRADED:

vc:                   14.1-h0510ff6_4                      --> 14-0                conda-forge

Downloading and Extracting Packages
protobuf-3.6.1 | 515 KB | ########## | 100%
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done

Installation complete.

Restarting R session...

@skeydan
Copy link

skeydan commented Oct 9, 2018

does reticulate work for you?

E.g.,

library(reticulate)
os <- import("os")
os$listdir(".")

@davidkeras
Copy link
Author

ya, reticulate seems to work. I tried running the 3 lines above and no error shows up.

@andrie
Copy link
Member

andrie commented Oct 10, 2018

@davidkeras , can you please wrap the script output in blocks separated with three backticks, so it's easier to read the output?

like this:

```r
r_code()
``` 

and

```
output of code
```

This will then render properly, e.g:

sessionInfo()

This will make it substantially easier to read your error report.

@andrie
Copy link
Member

andrie commented Oct 10, 2018

Also reported at:

On this last issue (#127), a user reports a fix:

I was able to fix the problem at least for me. In my case the problem was, that there was a path to an "old" python environment somehow hard coded in my PATH system environmental variables.
You can check on that by eighter using cmdand set PATH or from the R with e.g. strsplit(shell("set path",intern=TRUE),split=";")
After removing the old path and adding the current path to my r-tensorflow environment the system was ready to go. Probably the same should work if you don't add the new path to the system env variables but include it into the ~/.Renviron file. For me, I'm just happy that it works now, so I will not check for better solutions, but if someone does, I'm happy to improve my solution as well ;)

There is also an open StackOverflow question at ModuleNotFoundError: No module named 'rpytools' while using reticulate library

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

No branches or pull requests

3 participants