简体   繁体   English

使用pip安装PIL时出错

[英]Error Installing PIL using pip

I am Trying to install PIL using pip using the command: pip install PIL 我正在尝试使用pip使用pip安装PIL: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. 除了非常好的“许可问题” - 提示,也许您应该考虑使用“枕头” - 包( https://pypi.python.org/pypi/Pillow/ )而不是PIL本身。 the installation of PIL through a installation-manager is in most cases a pain in the ass job. 通过安装管理器安装PIL在大多数情况下是麻烦的工作。 pillow is a wrapper for PIL itself with the only purpose to provide a proper installable package. 枕头是PIL本身的包装材料,唯一的目的是提供适当的可安装包装。

Worked for me on Mac OSX 10.10.4 and Python 2.7.5 在Mac OSX 10.10.4和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 . 它显示异常,因为它需要, sudo命令执行。

Just type [enter image description here sudo pip install virtualenv 只需输入[在此输入图像描述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. 当您尝试在全球范围内安装PIL ,您似乎遇到了权限问题。

To continue with this try (which will also upgrade PIL if you have it installed already): 要继续此尝试(如果已安装PIL,还将升级PIL):

sudo pip install -U PIL 

If you want to experiment with PIL I recommend looking at using virtualenv . 如果你想试验PIL,我建议你看看使用virtualenv You create a virtual environment which you then activate and can install dependencies into with pip , without using sudo . 您创建一个虚拟环境然后activate并可以使用pip安装依赖项,而不使用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 . 这将创建一个包含环境以使用PIL并避免使用sudo

Note: you will have to activate the environment every time you want to use any of the requirements though. 注意:每次要使用任何要求时,都必须activate环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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