Installing a pillow for Python on Windows

I am new to Python and trying to install the Pillow package on Windows 7. I downloaded and started the MS Windows installer Pillow-2.2.1.win-amd64-py3.3.exe from. Looks like he set a fine. If I run a simple line of code:

from PIL import Image 

directly from the Python interpreter, it works fine. The help () on PIL gives me the contents of the package.

But when I try to run the same line of code from the script, I get ImportError: No module named PIL . What am I missing?

(Note that I was able to import sys and import MySQLdb from within the scripts just fine.)


Solved : sure enough, I run Python 2.7 when running scripts. (I think I vaguely remind you that you need to install an older version so that I can interact with MySQL.) Thanks to everyone for pointing out that I should check the version used.

+7
python windows python-imaging-library pillow
source share
2 answers

For third-party Windows modules, my go-to resource is Christoph Gohlke Python Python Extension Packs for Windows . You can find the latest version of Pillow here . Make sure you are working with the python.org version of Python.

As for your specific error, it's hard to say for sure without tracing, but make sure your script calls the correct version of Python. If you also installed Python 2.7, for example, your script might call this instead of 3.3.

+11
source share

In such cases, I just print sys.path at the beginning of the script problem and compare it with what works with the working python interpreter interpreter. In most cases, I ran the script with a different python interpreter.

+1
source share

All Articles