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 
    import requests
  File "F:\anaconda\lib\site-packages\requests\__init__.py", line 43, in 
    import urllib3
  File "F:\anaconda\lib\site-packages\urllib3\__init__.py", line 11, in 
    from . import exceptions
  File "F:\anaconda\lib\site-packages\urllib3\exceptions.py", line 3, in 
    from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
  File "", line 1007, in _find_and_load
  File "", line 982, in _find_and_load_unlocked
  File "", 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 "", 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 
    import email.parser
  File "F:\anaconda\lib\email\parser.py", line 12, in 
    from email.feedparser import FeedParser, BytesFeedParser
  File "F:\anaconda\lib\email\feedparser.py", line 27, in 
    from email._policybase import compat32
  File "F:\anaconda\lib\email\_policybase.py", line 9, in 
    from email.utils import _has_surrogates
  File "F:\anaconda\lib\email\utils.py", line 33, in 
    from email._parseaddr import quote
  File "F:\anaconda\lib\email\_parseaddr.py", line 16, in 
    import time, calendar
  File "F:\pythonProject\calendar.py", line 4, in 
    import jieba  # 词语切割
  File "F:\anaconda\lib\site-packages\jieba\__init__.py", line 14, in 
    from . import finalseg
  File "F:\anaconda\lib\site-packages\jieba\finalseg\__init__.py", line 6, in 
    from .._compat import *
  File "F:\anaconda\lib\site-packages\jieba\_compat.py", line 18, in 
    import pkg_resources
  File "F:\anaconda\lib\site-packages\pkg_resources\__init__.py", line 74, in 
    from pkg_resources.extern import appdirs
  File "", line 1007, in _find_and_load
  File "", line 986, in _find_and_load_unlocked
  File "", line 666, in _load_unlocked
  File "", 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 
    import win32com.shell
  File "F:\anaconda\lib\site-packages\win32com\__init__.py", line 6, in 
    import pythoncom
  File "F:\anaconda\lib\site-packages\pythoncom.py", line 2, in 
    import pywintypes
  File "F:\anaconda\lib\site-packages\win32\lib\pywintypes.py", line 136, in 
    __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 
    from email._parseaddr import quote
  File "F:\anaconda\lib\email\_parseaddr.py", line 16, in 
    import time, calendar
  File "F:\pythonProject\calendar.py", line 4, in 
    import jieba  # 词语切割
  File "F:\anaconda\lib\site-packages\jieba\__init__.py", line 14, in 
    from . import finalseg

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

calendar库函数和我本地的文件重名了,将本地的calendar.py改为calendarDemo.py就OK了

你可能感兴趣的:(笔记,python,爬虫)