Skip to content Skip to sidebar Skip to footer

ImportError: No Module Named Image, ImportError: No Module Named PIL -- Python, Anaconda, PIL, Pillow, Mac 10.10.3,

I'm using a Mac OS x 10.10.3 Yosemite, and Python 2.7.9 |Anaconda 2.2.0 (x86_64) for a lot of python stuff. I'm using eclipse, and google app engine. I'm running out of stack over

Solution 1:

The following does work for me:

from PIL import Image

And this does not work:

import Image

Pillow package

$ conda search pillow
Fetching package metadata: ....
pillow                       2.1.0                    py33_0  defaults        
                             2.1.0                    py27_0  defaults        
                             2.1.0                    py26_0  defaults        
                             2.3.1                    py34_0  defaults        
                             2.3.1                    py33_0  defaults        
                             2.3.1                    py27_0  defaults        
                             2.3.1                    py26_0  defaults        
                             2.4.0                    py34_0  defaults        
                             2.4.0                    py33_0  defaults        
                             2.4.0                    py27_0  defaults        
                             2.4.0                    py26_0  defaults        
                          .  2.5.1                    py34_0  defaults        
                             2.5.1                    py33_0  defaults        
                             2.5.1                    py27_0  defaults        
                             2.5.1                    py26_0  defaults        
                             2.7.0                    py34_0  defaults        
                             2.7.0                    py33_0  defaults        
                             2.7.0                    py27_0  defaults        
                             2.7.0                    py26_0  defaults        
                             2.7.0                    py34_1  defaults        
                             2.7.0                    py33_1  defaults        
                             2.7.0                    py27_1  defaults        
                             2.7.0                    py26_1  defaults        
                             2.8.1                    py34_1  defaults        
                             2.8.1                    py33_1  defaults        
                             2.8.1                    py27_1  defaults        
                             2.8.1                    py26_1  defaults        
                             2.8.1                    py34_2  defaults        
                             2.8.1                    py33_2  defaults        
                             2.8.1                    py27_2  defaults        
                             2.8.1                    py26_2  defaults        
                             2.8.2                    py34_0  defaults        
                             2.8.2                    py33_0  defaults        
                             2.8.2                    py27_0  defaults        
                             2.8.2                    py26_0  defaults        
                          *  2.9.0                    py34_0  defaults        
                             2.9.0                    py33_0  defaults        
                             2.9.0                    py27_0  defaults        
                             2.9.0                    py26_0  defaults  

Python path

$ python
Python 3.4.3 |Anaconda 2.1.0 (x86_64)| (default, Mar  6 2015, 12:07:41) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print (sys.path)
['', '/Users/erwin/anaconda/lib/python34.zip', '/Users/erwin/anaconda/lib/python3.4', '/Users/erwin/anaconda/lib/python3.4/plat-darwin', '/Users/erwin/anaconda/lib/python3.4/lib-dynload', '/Users/erwin/anaconda/lib/python3.4/site-packages', '/Users/erwin/anaconda/lib/python3.4/site-packages/Sphinx-1.3.1-py3.4.egg', '/Users/erwin/anaconda/lib/python3.4/site-packages/setuptools-18.1-py3.4.egg']

Image usage

This works both in my terminal and in Eclipse PyDev now.

>>> from PIL import Image
>>> a = Image.new("RGB", (512,512), "red")
>>> a.show()

Solution 2:

At first, try installing Pillow with (Capital letter P)

pip install Pillow

then use from PIL import Image "Pillow is a fork of PIL, the Python Imaging Library, which is no longer maintained. However, to maintain backwards compatibility, the old module name is used." From: pillow installed, but "no module named pillow" - python2.7 - Windows 7 - python -m install pillow


Solution 3:

Newer version of Pillow has been changed decleration of "image" as:

from PIL.Image import core as image

Solution 4:

I've been in the same position as you at least a few times, and I somehow managed to resolve it through other solutions. Then it broke again. Here is what I did that fixed it:

Open two finder windows.

In one, navigate to:

//anaconda/pkgs/pillow-3.2.0-py27_0/lib/python2.7/site-packages

In this folder, you will find the folder

PIL

Copy this folder and paste it somewhere accessible.

Now open your python 2.7 environment folder within the anaconda directory. For me, it's:

//anaconda/envs/py27/lib/python2.7/site-packages

You should only have to change the "py27" in that.

Even if there is already a folder in there named "PIL", put your copied PIL in the new site-packages folder. From what I can tell, the existing PIL folder in there is old or wrong, or something. Or pillow doesn't install it correctly. I think this amounts to a manual installation of a python module. Super fun.


Solution 5:

I was running into the same problem as OP:

  • macOS 10.12.5
  • Python 2.7.13 [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)] on darwin

The problem ended up being the the .py file I was trying to run.

At the top of the script there was a shebang: #!/usr/bin/python

However, my default python does not run from the system installation. I used homebrew to upgrade python, so my default path is:

$ which python
/usr/local/bin/python

I changed the shebang at the top to #!/usr/local/bin/python, and after that I was able to run my script (which was calling from PIL import Image).


Post a Comment for "ImportError: No Module Named Image, ImportError: No Module Named PIL -- Python, Anaconda, PIL, Pillow, Mac 10.10.3,"