pip install PIL没有安装到virtualenv中

Dro*_*oid 57 pip python-imaging-library

如何安装PIL?

>pip install PIL

Downloading/unpacking PIL
  Could not find any downloads that satisfy the requirement PIL  
  Some externally hosted files were ignored (use --allow-external PIL to allow). 
Cleaning up... 
No distributions at all found for PIL 
Storing debug log for failure in /root/.pip/pip.log 

>pip uninstall PIL
Can't uninstall 'PIL'. No files were found to uninstall.
Run Code Online (Sandbox Code Playgroud)

JCo*_*ton 144

pip install PIL --allow-external PIL --allow-unverified PIL

这是由于新版Pip的变化.跑pip --version,我愿意打赌你跑1.5.请在此处查看更改日志.此新的默认行为可增强安全性.在PIL的情况下,您安装的文件实际上来自effbot.org(因此--allow-external)并且PyPi没有校验和来保证有效性(因此--allow-unverified).

此外,您可以考虑使用Pillow替换PIL.

  • 好吧,看起来像Python 3.5.2`-allow-external`和`--allow-unverified`被弃用了,已经不再有任何影响......想想,`pip install pillow`似乎工作正常. (2认同)

小智 38

2016年阅读的最新信息:

--allow-external
Run Code Online (Sandbox Code Playgroud)

--allow-unverified
Run Code Online (Sandbox Code Playgroud)

最近被弃用了.不再支持使用pip在PyPi外部安装软件包:http://www.python.org/dev/peps/pep-0470/

作为替代方案,当您确实需要安装该外部包时,可以下载源代码并运行其setup.py.例如,对于PIL 1.1.7,请从http://www.pythonware.com/products/pil/下载,然后:

$ tar xvfz Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7
$ python setup.py install
Run Code Online (Sandbox Code Playgroud)

(来自PIL自述文件的^)

如果您只想将软件包安装到特定的virtualenv,您可以先激活您的virtualenv.**谢谢@Caumons

或者,在第三行替换你的virtualenv的'python'路径,例如:

$ /home/username/virtualenv-name/bin/python setup.py install
Run Code Online (Sandbox Code Playgroud)