ImportError: cannot import name chardet

核能气质少年 提交于 2019-12-01 23:51:33

As you can see from the traceback -

Traceback (most recent call last):
  File "CompanyScrapper-1.6.py", line 13, in <module>
  File "requests\__init__.pyc", line 58, in <module>
  File "requests\utils.pyc", line 26, in <module>
  File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet

You have a requests directory with a __init__.py . This is masking the requests package from the library , so when you try to import chardet or any such thing from requests library , it tries to search for it in this local package, and not the library one.

The best solution for this would be to rename the directory and your local package from requests to something else, so that the name does not conflict with any library packages.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!