# -*- coding:utf-8 -*-
#! /usr/bin/env python3
import requests
#引入 requests 库
AttributeError: '_SixMetaPathImporter' object has no attribute 'find_spec'
,
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 900, in _find_spec
AttributeError: '_SixMetaPathImporter' object has no attribute 'find_spec'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/noogler/Documents/python_files_sublimetext3/practice/draft7.py", line 3, in <module>
import requests
File "/usr/local/lib/python3.7/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/usr/local/lib/python3.7/site-packages/urllib3/__init__.py", line 7, in <module>
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/usr/local/lib/python3.7/site-packages/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 963, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 902, in _find_spec
File "<frozen importlib._bootstrap>", line 879, in _find_spec_legacy
File "<frozen importlib._bootstrap>", line 449, in spec_from_loader
File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 212, in is_package
return hasattr(self.__get_module(fullname), "__path__")
File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 116, in __getattr__
_module = self._resolve()
File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 113, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 71, in <module>
import email.parser
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/feedparser.py", line 27, in <module>
from email._policybase import compat32
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/utils.py", line 33, in <module>
from email._parseaddr import quote
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/_parseaddr.py", line 16, in <module>
import time, calendar
File "/Users/noogler/Documents/python_files_sublimetext3/practice/calendar.py", line 9, in <module>
cal = calendar.month(year,month)
TypeError: 'int' object is not callable
[Finished in 0.1s with exit code 1]
[cmd: ['/usr/local/bin/python3', '-u', '/Users/noogler/Documents/python_files_sublimetext3/practice/draft7.py']]
[dir: /Users/noogler/Documents/python_files_sublimetext3/practice]
[path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/aria2/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands]
import pygame 库是正常的
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
[Finished in 0.2s]
初学 python 不久,不确定还需要补充哪些信息帮忙定位,我会继续补充 自己 Google 了 2 天了还是没解决,希望有好心大佬帮忙,感激不尽 😂
1
leishi1313 2020-04-21 05:59:23 +08:00
把你的 ‘calendar.py’ 改个名吧
|
2
EricCartmann 2020-04-21 08:25:09 +08:00 via iPhone
自己写的 Python 文件名出问题了,Python 导入的时候最先找的是当前工程下的文件,所以在导 calendar 这个自带模块的时候找到你自己写的这个文件了。。以后最好不要用这样的英文名字,建议用拼音(狗头)
|
3
bany 2020-04-21 09:22:53 +08:00
从 log 上看```"/Users/noogler/Documents/python_files_sublimetext3/practice/calendar.py", line 9```第 9 行报错了,原因是你这个文件中有个 month 变量,刚好你的文件名与导入的包名是一样的(不建议这么取名),发生了冲突,在调用的时候,Python 查找的方式遵循`legb`: local->enclosing(闭包)->global->build-in 。最简单的改法就是把文件改了
|
4
cpluspython OP @leishi1313 可以了 感谢!
|
5
cpluspython OP @EricCartmann 明白了 😂 感谢!
|
6
cpluspython OP @bany 学习了学习了 我再好好整理下 感谢!
|