简体   繁体   中英

Error in importing requests module in python3

I am using requests module in my python program. It worked great in the previous day. But now, when importing requests module, it is showing a weird error. It is working great in python2 version. But shows error in python3. I googled it but can't find a solution. I haven't changed anything. Why it is showing this error.

Here it is:

>>> 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'

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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