• 全部
  • 互动交流
  • 文章分享

AttributeError: 'module' object has no attribute 'rcParams'

-柚子皮- aa NLP对话+推荐算法  2014-12-26 11:46:25
电脑系统win7 x64
电脑同时安装了python2.7和python3.4
也同时安装了matplotlib for 2.7 和3.4

在pycharm py文件中import matplotlib正常(解释器为python 3.4)
print(matplotlib.__file__ )
D:\python3.4.2\lib\site-packages\matplotlib\__init__.py

但在python console中import matplotlib出现错误:(解释器也为python 3.4)
AttributeError: 'module' object has no attribute 'rcParams'

网上在解决说:(应该是针对linux)
it looks like you have a matplotlib dir in your working directory that is being picked up and you probably don't want it.

You have the matplotlib source directory in your HOME directory and when you run from your home directory, it is being picked up instead of the installation directory. I usually name my src tree "mpl" to avoid this problem
这个好像不行
...全文
1059 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
badgirl-no1 2014-12-28
exporting PYTHONPATH causes matplotlib not to load http://matplotlib.1069221.n5.nabble.com/exporting-PYTHONPATH-causes-matplotlib-not-to-load-td22456.html
回复
-柚子皮- 2014-12-27
For Python 2.7 it works. However, I have checked this behavior on two computers with Python 3.4. The Matplotlib module object is broken if it was imported via the "pydev_import_hook" mechanism. I think changes in the import system in Python 3 are the cause of this problem I can confirm the same problem: in my case a fresh install (from nothing) of Anaconda 2.1.0 of Python 3.4.1. 'import matplotlib' works from an ipython session opened outside pycharm but fails inside. 的确是个bug!
回复
-柚子皮- 2014-12-27
解决了,重新下载安装pycharm就ok了!注意保存settings
回复
-柚子皮- 2014-12-27
cmd中import没错:
回复
panghuhu250 2014-12-27
这是pycharm的bug, 现在还没修好: http://forum.jetbrains.com/thread/PyCharm-2449, https://youtrack.jetbrains.com/issue/PY-14472.
回复
sprawling 2014-12-27
同时装两个更新模块的时候会有冲突吧,建议如果装两个,一个装在windows下面,一个装在linux下面.
回复
-柚子皮- 2014-12-27
python console: >>> import matplotlib Traceback (most recent call last): File "<input>", line 1, in <module> File "D:\PyCharm 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import module = self._system_import(name, globals, locals, fromlist, level) File "D:\python3.4.2\lib\site-packages\matplotlib\__init__.py", line 194, in <module> from matplotlib.rcsetup import (defaultParams, File "D:\PyCharm 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import module = self._system_import(name, globals, locals, fromlist, level) File "D:\python3.4.2\lib\site-packages\matplotlib\rcsetup.py", line 24, in <module> from matplotlib.colors import is_color_like File "D:\PyCharm 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import module = self._system_import(name, globals, locals, fromlist, level) File "D:\python3.4.2\lib\site-packages\matplotlib\colors.py", line 59, in <module> import matplotlib.cbook as cbook File "D:\PyCharm 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import module = self._system_import(name, globals, locals, fromlist, level) File "D:\PyCharm 4.0\helpers\pydev\pydev_import_hook.py", line 31, in do_import self._modules_to_patch[name]() #call activate function File "D:\PyCharm 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 73, in activate_matplotlib_inner gui, backend = find_gui_and_backend() File "D:\PyCharm 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 28, in find_gui_and_backend backend = matplotlib.rcParams['backend'] AttributeError: 'module' object has no attribute 'rcParams'
回复
-柚子皮- 2014-12-27
而且在pycharm py文件中import matplotlib正常 只有在python console中import matplotlib出错
回复
-柚子皮- 2014-12-27
可是装的numpy和scipy都import正常没有冲突,只有matplotlib引入出现这种错误,两个版本的我都想要呢 这个怎么解决呢?
回复
相关推荐
发帖
脚本语言
创建于2007-08-27

3.7w+

社区成员

JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
申请成为版主
帖子事件
创建了帖子
2014-12-26 11:46
社区公告

CSDN 脚本语言社区接受专栏投稿(专栏会在顶部创建专属你的栏目),投稿需满足以下要求:

  • 脚本语言技术相关;
  • 文章持续更新,保持活跃;
  • 内容清晰明了,干货为主;
  • 文章排版有序,有条有理。

本社区开通招聘专栏,发布招聘信息请联系版主,发布者需要保证招聘信息真实有效,CSDN 平台和版主不对招聘内容负责!

联系方式:私聊版主、发送邮件、QQ联系等均可: