Reputation: 3549
On Windows 10 pro, I am running a docker image with python and jupyter installed. I can start the docker image and from that shell start the jupyter notebook fine. Both python2 and python3 kernels are available. PIL and Pillow are installed but I cannot import them. See below:
(I have indicated the contents of each jupyter cell with double asterisks.
The result of each cell then simply follows below it)
**!pip install Image**
Requirement already satisfied: Image in /usr/local/lib/python3.6/dist-packages (1.5.27)
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from Image) (5.1.0)
Requirement already satisfied: django in /usr/local/lib/python3.6/dist-packages (from Image) (2.2)
Requirement already satisfied: sqlparse in /usr/local/lib/python3.6/dist-packages (from django->Image) (0.3.0)
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from django->Image) (2018.3)
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
**!pip install Pillow**
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (5.1.0)
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
**!python -m pip install pillow**
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (5.1.0)
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
**import PIL**
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-70d569469e06> in <module>()
----> 1 import PIL
ImportError: No module named PIL
**import PIL.Image**
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-df3f6661ddbf> in <module>()
----> 1 import PIL.Image
ImportError: No module named PIL.Image
**import pillow**
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-11-e32915389b2c> in <module>()
----> 1 import pillow
ImportError: No module named pillow
But when I exit the notebook and start an interactive python session in the running docker container, PIL is found easily:
root@7092fc2336d3:/# python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>>
Upvotes: 1
Views: 797
Reputation: 3549
well this is weird. It turns out that the pip in jupyter was installing in the python3 site packages but the python in the jupyter notebook was looking in the python2 site packages. so when I installed pillow in a jupyter cell like so
!/usr/bin/python2.7 -m pip install Pillow
now this works
import PIL.Image
Upvotes: 1