requests import就报错
TypeError when importing from pythonAsk Questionup vote0down votefavoriteI'm having problems using the requests library. I used pip to install it and I also intalled through github and the inst...
TypeError when importing from python
up vote0down votefavorite
I'm having problems using the requests library. I used pip to install it and I also intalled through github and the installation goes just fine. But when I try to import the lib, I get this error:
Python 2.7.14+ (default, Mar 13 2018, 15:23:44)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 12, in <module>
from cryptography import x509
File "/usr/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 8, in <module>
from cryptography.x509.base import (
File "/usr/lib/python2.7/dist-packages/cryptography/x509/base.py", line 16, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "/usr/lib/python2.7/dist-packages/cryptography/x509/extensions.py", line 24, in <module>
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
File "/usr/lib/python2.7/dist-packages/cryptography/x509/general_name.py", line 18, in <module>
from cryptography.x509.name import Name
File "/usr/lib/python2.7/dist-packages/cryptography/x509/name.py", line 28, in <module>
_ASN1_TYPE_TO_ENUM = dict((i.value, i) for i in _ASN1Type)
TypeError: 'type' object is not iterable
>>>
I saw in another post a person saying something about the PATH, but I didn't understand... Something related to a conflict between /usr/bin and /usr/local/bin. I don't know if this have something to do with it. I also have used pip2.7 to install the lib and it shows in the pip list
command. I'd appreciate any help.
python python-requests typeerror
asked Mar 27 at 9:56
51
-
1
Have you seen this: github.com/pyca/cryptography/issues/4020 and tried the
sudo pip uninstall enum
followed bysudo pip install enum34
? – FlyingTeller Mar 27 at 10:16 -
Oh man, I saw this before, but for some reason I forgot to uninstall the enum. Problem solved. Thanks! – Ulisses Alves Mar 27 at 10:22
-
I'll post it as an answer for future readers that find this page – FlyingTeller Mar 27 at 10:27
add a comment
1 Answer
up vote0down voteaccepted
The issue is in the cryptography module. It can also be found on the github page. The solution seems to be that you need to replace the enum package:
pip uninstall enum
pip install enum34
Note that you need to use sudo pip
if you are using packages from /usr/
更多推荐
所有评论(0)