在python3中导入请求模块时出错

时间:2019-03-06 13:17:12

标签: python python-3.x python-2.7 python-requests

我正在python程序中使用请求模块。前一天效果很好。但是现在,在导入请求模块时,它显示了一个奇怪的错误。它在python2版本中运行良好。但是在python3中显示错误。我用谷歌搜索,但找不到解决方案。我什么都没改变。为什么显示此错误。

这里是:

>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/paulsteven/.local/lib/python3.5/site-packages/requests/__init__.py", line 95, in <module>
    from urllib3.contrib import pyopenssl
  File "/home/paulsteven/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/rand.py", line 11, in <module>
    from OpenSSL._util import (
  File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/_util.py", line 3, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 188, in <module>
    _verify_package_version(cryptography.__version__)
  File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 175, in _verify_package_version
    so_package_version = ffi.string(lib.CRYPTOGRAPHY_PACKAGE_VERSION)
AttributeError: cffi library '_openssl' has no function, constant or global variable named 'CRYPTOGRAPHY_PACKAGE_VERSION'

1 个答案:

答案 0 :(得分:0)

重新安装cryptography软件包将解决此问题。