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

Issue with PIL import Image #1

Open
nabriis opened this issue Jan 12, 2021 · 1 comment
Open

Issue with PIL import Image #1

nabriis opened this issue Jan 12, 2021 · 1 comment

Comments

@nabriis
Copy link

nabriis commented Jan 12, 2021

Hi using this image for R on windows WSL 2 I seem to run into an issue with "Pillow" not being installed when running some ML code in rstudio.

I tried
reticulate::py_install('pillow',pip = TRUE)

but get the following error
Error: could not find a Python environment for /usr/local/bin/python

Even though we have

> reticulate::py_config()
python:         /usr/local/bin/python
libpython:      /usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so
pythonhome:     //usr://usr
version:        3.6.9 (default, Nov  7 2019, 10:44:02)  [GCC 8.3.0]
numpy:          /usr/local/lib/python3.6/dist-packages/numpy
numpy_version:  1.18.1
tensorflow:     /usr/local/lib/python3.6/dist-packages/tensorflow

In the Jupyter notebook this code returns the same path:

import sys
from PIL import Image
sys.modules['Image'] = Image 
from PIL import Image
print(Image.__file__)
import Image
print(Image.__file__)

So it seems to be an issue with rstudio not finding the pillow install somehow.

@angelsevillacamins
Copy link
Contributor

Dear Nabriis,
Dependency management in tricky in this scenario since rstudio is running with the ubuntu user but the installation is carried out as root. I think that you have two options:

  1. Change the Dockerfile adding the new dependencies:
    For that modify the line that reads:
RUN pip install rpy2

to:

RUN pip install rpy2 pillow

Create again the image using this new Dockerfile and push it to Dockerhub. This option will persist the changes and it is my favorite.

  1. Get a bash shell in the container and then run as root:
pip install pillow

However, this option won't persist your changes and you have to run it every time that you restart the container.
Let me know if that solve your problem.

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

2 participants