Traceback (most recent call last): File “***“, line 1, in <module> import requests File “

这篇具有很好参考价值的文章主要介绍了Traceback (most recent call last): File “***“, line 1, in <module> import requests File “。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

先说结论:

python库函数和我本地的py文件重名了 

今天跑之前一个爬虫程序突然报错:

Traceback (most recent call last):
  File "F:\pythonProject\main.py", line 1, in <module>
    import requests
  File "F:\anaconda\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "F:\anaconda\lib\site-packages\urllib3\__init__.py", line 11, in <module>
    from . import exceptions
  File "F:\anaconda\lib\site-packages\urllib3\exceptions.py", line 3, in <module>
    from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "F:\anaconda\lib\site-packages\urllib3\packages\six.py", line 192, in find_spec
    return spec_from_loader(fullname, self)
  File "<frozen importlib._bootstrap>", line 431, in spec_from_loader
  File "F:\anaconda\lib\site-packages\urllib3\packages\six.py", line 222, in is_package
    return hasattr(self.__get_module(fullname), "__path__")
  File "F:\anaconda\lib\site-packages\urllib3\packages\six.py", line 121, in __getattr__
    _module = self._resolve()
  File "F:\anaconda\lib\site-packages\urllib3\packages\six.py", line 118, in _resolve
    return _import_module(self.mod)
  File "F:\anaconda\lib\site-packages\urllib3\packages\six.py", line 87, in _import_module
    __import__(name)
  File "F:\anaconda\lib\http\client.py", line 71, in <module>
    import email.parser
  File "F:\anaconda\lib\email\parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "F:\anaconda\lib\email\feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "F:\anaconda\lib\email\_policybase.py", line 9, in <module>
    from email.utils import _has_surrogates
  File "F:\anaconda\lib\email\utils.py", line 33, in <module>
    from email._parseaddr import quote
  File "F:\anaconda\lib\email\_parseaddr.py", line 16, in <module>
    import time, calendar
  File "F:\pythonProject\calendar.py", line 4, in <module>
    import jieba  # 词语切割
  File "F:\anaconda\lib\site-packages\jieba\__init__.py", line 14, in <module>
    from . import finalseg
  File "F:\anaconda\lib\site-packages\jieba\finalseg\__init__.py", line 6, in <module>
    from .._compat import *
  File "F:\anaconda\lib\site-packages\jieba\_compat.py", line 18, in <module>
    import pkg_resources
  File "F:\anaconda\lib\site-packages\pkg_resources\__init__.py", line 74, in <module>
    from pkg_resources.extern import appdirs
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 565, in module_from_spec
  File "F:\anaconda\lib\site-packages\pkg_resources\extern\__init__.py", line 52, in create_module
    return self.load_module(spec.name)
  File "F:\anaconda\lib\site-packages\pkg_resources\extern\__init__.py", line 37, in load_module
    __import__(extant)
  File "F:\anaconda\lib\site-packages\pkg_resources\_vendor\appdirs.py", line 560, in <module>
    import win32com.shell
  File "F:\anaconda\lib\site-packages\win32com\__init__.py", line 6, in <module>
    import pythoncom
  File "F:\anaconda\lib\site-packages\pythoncom.py", line 2, in <module>
    import pywintypes
  File "F:\anaconda\lib\site-packages\win32\lib\pywintypes.py", line 136, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "F:\anaconda\lib\site-packages\win32\lib\pywintypes.py", line 129, in __import_pywin32_system_module__
    assert sys.modules[modname] is not old_mod
AssertionError

Process finished with exit code 1

 观察报错信息有这么一句:

File "F:\anaconda\lib\email\utils.py", line 33, in <module>
    from email._parseaddr import quote
  File "F:\anaconda\lib\email\_parseaddr.py", line 16, in <module>
    import time, calendar
  File "F:\pythonProject\calendar.py", line 4, in <module>
    import jieba  # 词语切割
  File "F:\anaconda\lib\site-packages\jieba\__init__.py", line 14, in <module>
    from . import finalseg

点进去F:\pythonProject\calendar.py文件和F:\anaconda\lib\email\_parseaddr.py 发现

calendar库函数和我本地的文件重名了,将本地的calendar.py改为calendarDemo.py就OK了文章来源地址https://www.toymoban.com/news/detail-617089.html

到了这里,关于Traceback (most recent call last): File “***“, line 1, in <module> import requests File “的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包