m0_64342167
2022-02-08 17:23
采纳率: 100%
浏览 64

pycharm运行requests库时出现错误

详细问题如下

import requests
r=requests.get('http://www.baidu.com')
r=r.text
print(r)

运行后报错如下


C:\Users\qhx\PycharmProjects\pythonProject1\venv\Scripts\python.exe C:/Users/qhx/PycharmProjects/pythonProject1/666.py
Traceback (most recent call last):
  File "C:\Users\qhx\PycharmProjects\pythonProject1\666.py", line 1, in <module>
    import requests
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 29, in <module>
    from .connection import (
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connection.py", line 39, in <module>
    from .util.ssl_ import (
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\util\__init__.py", line 3, in <module>
    from .connection import is_connection_dropped
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\util\connection.py", line 3, in <module>
    from .wait import wait_for_read
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\util\wait.py", line 1, in <module>
    from .selectors import (
  File "C:\Users\qhx\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\util\selectors.py", line 14, in <module>
    from collections import namedtuple, Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Users\qhx\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)

进程已结束,退出代码1

requests拆了重新装,pip重新安装requests,pip更新都试过了行不通,求答疑

img

3条回答 默认 最新

相关推荐 更多相似问题