python - import matplotlib.pyplot时报错
问题描述
今天在import matplotlib.pyplot时报错:Traceback (most recent call last): File 'C:UserslenovoDesktopzq.py', line 5, in <module>
import matplotlib.pyplot
File 'C:Python34libsite-packagesmatplotlib__init__.py', line 129, in <module>
from six.moves.urllib.request import urlopen
File 'C:Python34libsite-packagessix.py', line 92, in get
result = self._resolve()
File 'C:Python34libsite-packagessix.py', line 160, in _resolve
module = _import_module(self.mod)
File 'C:Python34libsite-packagessix.py', line 82, in _import_module
__import__(name)
File 'C:Python34liburllibrequest.py', line 88, in <module>
import http.client
File 'C:Python34libhttpclient.py', line 69, in <module>
import email.parser
File 'C:Python34libemailparser.py', line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File 'C:Python34libemailfeedparser.py', line 27, in <module>
from email import message
File 'C:Python34libemailmessage.py', line 10, in <module>
import uu
File 'C:UserslenovoDesktopuu.py', line 4, in <module>
import requests
File 'C:Python34libsite-packagesrequests-2.9.1-py3.4.eggrequests__init__.py', line 58, in <module>
from . import utils
File 'C:Python34libsite-packagesrequests-2.9.1-py3.4.eggrequestsutils.py', line 12, in <module>
import cgi
File 'C:Python34libcgi.py', line 39, in <module>
from email.parser import FeedParser
ImportError: cannot import name ’FeedParser’我只是一个多月没用matplotlib模块,以前都是好好的,以前写的有用matplotlib模块的东西现在都报错,这是要重装吗?我刚在stackoverflow.com中找到一个相似的问题:https://stackoverflow.com/que...,因为不懂英文,用google翻译好像原因是在同一文件夹中有一个同名脚本,但我看得不太明白,请大家帮助,谢谢还有就是这几天每次运行脚本的时候都会自动生成一个__pycache__文件夹,里面有个xxxx.cpython-34.pyc
问题解答
回答1:找到了,原来是有一个叫uu.py的文件可能是重名了,谢谢大家
回答2:检查下你当前目录是否有py文件和所相关的库名同名了
回答3:错误原因:
from email.parser import FeedParser
ImportError: cannot import name ’FeedParser’
在python3环境下FeedParser是有的,你的没有,可能原因:当前目录有email.py文件 or email目录
相关文章: