我尝试在Pycharm控制台中导入matplotlib.pyplt
import matplotlib.pyplot as plt
然后我得到:
Traceback (most recent call last):
File "D:\Program Files\Anaconda2\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-eff513f636fd>", line 1, in <module>
import matplotlib.pyplot as plt
File "D:\Program Files\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "D:\Program Files\Anaconda2\lib\site-packages\matplotlib\pyplot.py", line 2512, in <module>
install_repl_displayhook()
File "D:\Program Files\Anaconda2\lib\site-packages\matplotlib\pyplot.py", line 165, in install_repl_displayhook
ip.enable_gui(ipython_gui_name)
File "D:\Program Files\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 125, in enable_gui
raise UsageError("%s" % e)
UsageError: Invalid GUI request 'qt5', valid ones are:['pyglet', 'osx', 'none', 'gtk3', 'tk', 'qt', 'glut', 'gtk', 'qt4', 'wx']
Traceback (most recent call last):
File "D:\Program Files\Anaconda2\lib\site-packages\IPython\core\events.py", line 74, in trigger
func(*args, **kwargs)
File "D:\Program Files\Anaconda2\lib\site-packages\matplotlib\pyplot.py", line 147, in post_execute
if matplotlib.is_interactive():
AttributeError: 'NoneType' object has no attribute 'is_interactive'
Error in callback <function post_execute at 0x0000000008AAD438> (for post_execute):
我的python版本:
Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] on win32
但是当我尝试在Ipython中导入matplotlib时,它可以工作。我的Pycharm控制台有什么问题吗?
答案 0 :(得分:0)
我实际上遇到了相反的问题,因为启动Ipython失败并出现相同的错误(matplotlib.is_interactive())
我有%pylab inline
作为我的Ipython启动设置(~/.ipython/profile_default/startup/start.ipy
)的一部分,这些设置搞砸了,删除它解决了这个问题。这在更新我的Ipython和Anaconda版本后开始发生。
我的想法是类似于幕后发生的事情。也许设置一个类似的启动脚本来使用提供的代码@Chao执行反向可能会有效。