Pip错误:'module'对象没有属性'Cryptography_HAS_SSL_ST'

时间:2016-12-12 13:45:06

标签: python linux ubuntu openssl pip

我尝试从pip安装并继续获得类似的错误。

$ pip install quandl
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/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  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/lib/python2.7/dist-packages/requests/__init__.py", line 53, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module>
    import OpenSSL.SSL
  File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module>
    if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'

现在即使我试图安装不同的pip模块我也得到同样的错误。有什么解决方案吗?这是由于在下载pip模块时意外杀死进程造成的。

请帮我完成纠正此错误的必要步骤。

我尝试安装此

$ pip install -U cryptography
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/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  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/lib/python2.7/dist-packages/requests/__init__.py", line 53, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module>
    import OpenSSL.SSL
  File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module>
    if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'

9 个答案:

答案 0 :(得分:30)

Ubuntu 16.04.3:

我想通过删除python-openssl包(以及它的依赖关系)来解决这个问题:

apt-get --auto-remove remove python-openssl

然后使用pip安装最新版本:

pip install pyOpenSSL

当然,如果你安装另一个依赖它的apt软件包,它会把它拉回来。我希望你从现在开始使用pip而不是apt,它应该没问题。 / p>

编辑:截至2019年1月,这个问题似乎不再存在。

答案 1 :(得分:11)

我能够通过删除openssl python lib并重新安装(安装前清除不起作用)来解决这个问题:

itertools

答案 2 :(得分:2)

要在RHEL / CentOS上修复它:

sudo rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
sudo yum install pyOpenSSL

这在CentOS 7上为我做了!干杯!

答案 3 :(得分:1)

快速修复

将OpenSSL文件夹移动到OpenSSLBAK(例如)以避免错误

function storedProcedureQuery($firstName, $lastName, $phoneExtension, $updateEmployeeRecord, $commitUpdate)
{
    "
        exec [dbo].[usp_PhoneRemoveDuplicateExtensions_upd]
        @firstName = '$firstName',
        @lastName = '$lastName',
        @phoneExtension = '$phoneExtension',
        @updateEmployeeRecord = '$updateEmployeeRecord',
        @commitUpdate = '$commitUpdate'
    "
}

应该是好的

答案 4 :(得分:1)

我收到了这个错误并通过执行这些步骤解决了这个问题(不要忘记自己设置用户名):

rm -rf /home/<Your Username>/.local/lib/python2.7/site-packages/OpenSSL
sudo rm -rf usr/local/lib/python2.7/dist-packages/OpenSSL/
pip install pyOpenSSL

答案 5 :(得分:1)

尝试执行以下操作:

$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL
$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/pyOpenSSL-0.15.1.egg-info

在最后一行中,您可能有另一个版本的pyOpenSSL,请指定您的。

答案 6 :(得分:1)

如果甚至点子不起作用,请尝试以下操作:

sudo easy_install -U cffi
sudo easy_install -U cryptography

对我有用。

答案 7 :(得分:0)

尝试重新安装python,它将解决您的许多问题,

sudo apt-get install --reinstall python2.7
重新安装后,

和pip将丢失,请执行

sudo apt-get install python-pip

答案 8 :(得分:-1)

尝试从here下载合适的wheel文件,具体取决于您的操作系统和python版本。然后将此文件添加到Python / Scripts并使用以下代码进行安装。

let badgeNumber = content.badge as! Int

wheel文件包含所有依赖项。