gpt4 book ai didi

python - 无法从 Twython 导入 twython : ProtocolError and name certs error

转载 作者:行者123 更新时间:2023-11-30 23:19:31 31 4
gpt4 key购买 nike

使用 python 时,我在导入 twython 时遇到问题。安装似乎没问题,但由于某种原因,我收到以下错误。第一次尝试导入时,出现错误“ImportError:无法导入名称 ProtocolError”,随后的每次尝试都会导致以下错误“ImportError:无法导入名称证书”。可能有一个简单的解决方案,但我不知所措。

In [1]: from twython import Twython
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-d48648e29d1e> in <module>()
----> 1 from twython import Twython

/Users/Rush/build/bdist.macosx-10.5-x86_64/egg/twython/__init__.py in <module>()

/Users/Rush/build/bdist.macosx-10.5-x86_64/egg/twython/api.py in <module>()

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/__init__.py in <module>()
56 pass
57
---> 58 from . import utils
59 from .models import Request, Response, PreparedRequest
60 from .api import request, get, head, post, patch, put, delete, options

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/utils.py in <module>()
23 from . import __version__
24 from . import certs
---> 25 from .compat import parse_http_list as _parse_list_header
26 from .compat import (quote, urlparse, bytes, str, OrderedDict, unquote, is_py2,
27 builtin_str, getproxies, proxy_bypass)

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/compat.py in <module>()
5 """
6
----> 7 from .packages import charade as chardet
8
9 import sys

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/packages/__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from . import urllib3

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/__init__.py in <module>()
14
15
---> 16 from .connectionpool import (
17 HTTPConnectionPool,
18 HTTPSConnectionPool,

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py in <module>()
31 from .packages.ssl_match_hostname import CertificateError
32 from .packages import six
---> 33 from .connection import (
34 DummyConnection,
35 HTTPConnection, HTTPSConnection, VerifiedHTTPSConnection,

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/connection.py in <module>()
39 )
40 from .packages.ssl_match_hostname import match_hostname
---> 41 from .util import (
42 assert_fingerprint,
43 resolve_cert_reqs,

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/__init__.py in <module>()
16 )
17
---> 18 from .retry import Retry
19 from .url import (
20 get_host,

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/util/retry.py in <module>()
2 import logging
3
----> 4 from ..exceptions import (
5 ProtocolError,
6 ConnectTimeoutError,

ImportError: cannot import name ProtocolError



#####################################################################################
#####################################################################################
#####################################################################################




In [2]: from twython import Twython
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-d48648e29d1e> in <module>()
----> 1 from twython import Twython

/Users/Rush/build/bdist.macosx-10.5-x86_64/egg/twython/__init__.py in <module>()

/Users/Rush/build/bdist.macosx-10.5-x86_64/egg/twython/api.py in <module>()

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/__init__.py in <module>()
56 pass
57
---> 58 from . import utils
59 from .models import Request, Response, PreparedRequest
60 from .api import request, get, head, post, patch, put, delete, options

/Users/Rush/anaconda/lib/python2.7/site-packages/requests/utils.py in <module>()
22
23 from . import __version__
---> 24 from . import certs
25 from .compat import parse_http_list as _parse_list_header
26 from .compat import (quote, urlparse, bytes, str, OrderedDict, unquote, is_py2,

ImportError: cannot import name certs

最佳答案

这似乎是这个问题的表现:https://github.com/kennethreitz/requests/issues/2028
我通过重新安装请求解决了这个问题:
pip 卸载请求
进而
pip 安装请求

关于python - 无法从 Twython 导入 twython : ProtocolError and name certs error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26024116/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com