gpt4 book ai didi

python - Oauth 的导入错误

转载 作者:太空狗 更新时间:2023-10-29 21:24:15 25 4
gpt4 key购买 nike

我在 windows 上使用 Python 运行相同的代码它工作正常现在它突然改变更新程序我发现错误 ImportError : cannot import name to_native_string 你能帮我解释为什么会出现这个错误吗?

Traceback (most recent call last):
File "C:\Users\inla\Desktop\tweepy2\tweepy1.py", line 1, in <module>
from tweepy import Stream
File "C:\Users\inla\Desktop\tweepy2\tweepy\__init__.py", line 16, in <module>
from tweepy.auth import OAuthHandler, AppAuthHandler
File "C:\Users\inla\Desktop\tweepy2\tweepy\auth.py", line 9, in <module>
from requests_oauthlib import OAuth1Session, OAuth1
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.1-py2.7.egg\requests_oauthlib\__init__.py", line 1, in <module>
from .oauth1_auth import OAuth1
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.1-py2.7.egg\requests_oauthlib\oauth1_auth.py", line 10, in <module>
from requests.utils import to_native_string
ImportError: cannot import name to_native_string

最佳答案

检查您安装的 requests 版本。

requests.utils.to_native_stringrequests 2.0.0 开始可用。

requests 升级到最新版本将解决您的问题。


C:\Users\falsetru>pip install requests==1.2.3
Downloading/unpacking requests==1.2.3
...

Successfully installed requests
Cleaning up...

C:\Users\falsetru>python -c "from requests.utils import to_native_string"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name to_native_string

C:\Users\falsetru>pip uninstall -y requests
Uninstalling requests:
Successfully uninstalled requests

C:\Users\falsetru>pip install requests==2.0.0
Downloading/unpacking requests==2.0.0
...

Successfully installed requests
Cleaning up...

C:\Users\falsetru>python -c "from requests.utils import to_native_string"

C:\Users\falsetru>

关于python - Oauth 的导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24954974/

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