简体   繁体   中英

Error Installing PIL using pip

I am Trying to install PIL using pip using the command: pip install PIL

but i am getting the following error and i have no idea what it means. Could someone please help me out.

nishant@nishant-Inspiron-1545:~$ pip install PIL
Requirement already satisfied (use --upgrade to upgrade): PIL in /usr/lib/python2.7/dist-packages/PIL
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 104, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 265, in run
requirement_set.cleanup_files(bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1081, in cleanup_files
rmtree(dir)
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 29, in rmtree
onerror=rmtree_errorhandler)
File "/usr/lib/python2.7/shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 46, in rmtree_errorhandler
os.chmod(path, stat.S_IWRITE)
OSError: [Errno 1] Operation not permitted: '/home/nishant/build/pip-delete-this-directory.txt'

Storing complete log in /home/nishant/.pip/pip.log
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.1', 'console_scripts', 'pip-2.7')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 116, in main
return command.main(args[1:], options)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 141, in main
log_fp = open_logfile(log_fn, 'w')
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 168, in open_logfile
log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/home/nishant/.pip/pip.log'

You have a permission problem. Try:

sudo pip install -U PIL

besides the very good "permission problem"-hints, maybe you should consider using the "pillow"-package ( https://pypi.python.org/pypi/Pillow/ ) instead PIL itself. the installation of PIL through a installation-manager is in most cases a pain in the ass job. pillow is a wrapper for PIL itself with the only purpose to provide a proper installable package.

Worked for me on Mac OSX 10.10.4 and Python 2.7.5

sudo pip install pillow

of course you must have pip pre-installed for this to work

It is showing Exception because it requires , sudo command tu execute .

Just type [enter image description here sudo pip install virtualenv

After successful installation, it will show you like this . Successful installation pip Image

It looks like you have a permission issue as you're trying to install PIL globally.

To continue with this try (which will also upgrade PIL if you have it installed already):

sudo pip install -U PIL 

If you want to experiment with PIL I recommend looking at using virtualenv . You create a virtual environment which you then activate and can install dependencies into with pip , without using sudo .

For example:

# Change into home directory
cd ~/
# Make 'environments' folder and change into it
mkdir environments && cd $!
# Create virtual environment and change into it
virtualenv test_environment && cd $!
# Activate the environment
source bin/activate
# Install PIL
pip install PIL

This will create a contained environment to use PIL in and avoids using sudo .

Note: you will have to activate the environment every time you want to use any of the requirements though.

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