无法使用 pip 安装 Python 图像库

无法使用 pip 安装 Python 图像库

我试图通过运行 在 Ubuntu 15.10 上安装 Python 图像库pip install PIL。当我尝试运行该程序 (甚至pip uninstall PIL) 时,我收到此错误:

Traceback (most recent call last):   File "/usr/bin/pip", line 9, in
<module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()   File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 357,
in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)   File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2394,
in load_entry_point
    return ep.load()   File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2108,
in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])   File
"/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in
<module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa   File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9,
in <module>
    from pip.download import path_to_url   File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in
<module>
    import requests, six   File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line
53, in <module>
    from .packages.urllib3.contrib import pyopenssl   File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py",
line 43, in <module>
    ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD, AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3

有人能解释为什么我无法安装或卸载 pip 吗?

答案1

PIL 有一个新的分支,叫做枕头,您可以通过输入以下命令来安装:

sudo apt-get build-dep python-imaging
sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
sudo pip install Pillow

您可以看到官方文档页面了解更多信息。

要验证版本,只需输入:

>>> import PIL
>>> PIL.VERSION
'x.x.x'

x.x.x是版本号

相关内容