简体   繁体   中英

can't download and install python image library

I'm trying to download and install pythons image library PIL or pillow. I've looked at this question ( No module named Image ) and this question ( Can't install Python Imaging Library using pip ) and although I seemed to be having the same problem none of the answers helped me.

I use a mac with OSX 10.11.4 and my python interpreter is versions 2.7.10

Here is what I have tried to do:

download the tar ball (Python Imaging Library 1.1.7 Source Kit from http://www.pythonware.com/products/pil/#pil117 ) and unzip (the result is a folder called Imaging-1.1.7). I have this folder in my downloads folder. I then ran this in the command line:

pip install pillow

and this is what I got back:

Requirement already satisfied (use --upgrade to upgrade): pillow in /usr/local/lib/python3.5/site-packages

I then tried to run this python script:

from PIL import Image

but I got this error:

python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import Image
ImportError: No module named Image

I am very confused, I have never been able to download and install any modules before because I have had similar problems, so if your help will be greatly appreciated as it will allow me to download other modulus too. thanks in advance

Thanks so far for the help but nothing suggested has worked. I tried to download python 3.5.1 from this site ( https://www.python.org/downloads/ ) but when I run this command (python -V) in command line it still tells me I am using version 2.7.10

Also, I went into my applications folder to see if I had PIL and uninstall it if I did because it cannot coexist with pillow (according to one the answers so far) but I couldn't find it there. Am I looking in the wrong place or do I simply not have it?

Anyway, still haven't figured it out yet. It would be great if I could have some advice on downloading and installing stuff in general because, like I said before, I've never been able to download anything and have it actually work.

Python 2.7 and 3.3 have their own package locations. Since you have version 2.7 and 3.3 installed, you must do the following:

pip2 install pillow

You have to use sudo, and specify which version of pip:

sudo pip2 install Pillow
or
sudo pip3 install Pillow

Also, did you read the documentation :

Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.

You have a conflict in versions. And there's a difference between downloading a zip file and installing from pip.

I hope that helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM