gpt4 book ai didi

python - 导入错误:无法导入名称 'certs'

转载 作者:行者123 更新时间:2023-12-02 01:38:08 32 4
gpt4 key购买 nike

过去 2 天我遇到了此错误。这似乎是 python requests 库的问题,但我已经重新安装了好几次了,但没有成功。

Traceback (most recent call last):
File "project-src/bla-blah/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "project-src\env\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "project-src\env\lib\site-packages\django\core\management\__init__.py", line 354, in execute
django.setup()
File "project-src\env\lib\site-packages\django\__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "project-src\env\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "project-src\env\lib\site-packages\django\apps\config.py", line 112, in create
mod = import_module(mod_path)
File "C:\Python34\lib\importlib\__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "project-src\env\lib\site-packages\social\apps\django_app\__init__.py", line 14, in <module>
from social.apps.django_app.utils import load_strategy
File "project-src\env\lib\site-packages\social\apps\django_app\utils.py", line 12, in <module>
from social.backends.utils import get_backend
File "project-src\env\lib\site-packages\social\backends\utils.py", line 2, in <module>
from social.backends.base import BaseAuth
File "project-src\env\lib\site-packages\social\backends\base.py", line 1, in <module>
from requests import request, ConnectionError
File "project-src\env\lib\site-packages\requests\__init__.py", line 58, in <module>
from . import utils
File "project-src\env\lib\site-packages\requests\utils.py", line 24, in <module>
from . import certs

ImportError: cannot import name 'certs'

可能是两天前 Windows 7 更新的问题,因为这是最近几天唯一发生变化的事情。

顺便说一下,我使用的是带有 virtualenv 的 python 3.4、PyCharm 3.4.1 IDE 和 Win7。

certs.py 中存在有问题的代码(最后一行):

try:
from certifi import where
except ImportError:
def where():
"""Return the preferred certificate bundle."""
# vendored bundle inside Requests
return os.path.join(os.path.dirname(__file__), 'cacert.pem')

最佳答案

这对我有用(重新安装请求库):


pip 卸载请求
pip 安装请求

关于python - 导入错误:无法导入名称 'certs',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26928672/

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