我已经通过conda
安装了基本的os和Pycharm以及整个python堆栈,现在在ipython
sesssion中启动交互式matplotlib时遇到了麻烦。
这是pycharm的ipython会话:
/home/foo/.conda/envs/myenv3/bin/python3.5 /opt/pycharm-2016.2.3/helpers/pydev/pydevconsole.py 41070 33134
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
Type "copyright", "credits" or "license" for more information.
IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
PyDev console: using IPython 5.0.0
import sys; print('Python %s on %s' % (sys.version, sys.platform))
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
如果我尝试导入pyplot
,会发生以下情况:
In[4]: import matplotlib.pyplot as plt
Traceback (most recent call last):
File "/opt/pycharm-2016.2.3/helpers/pydev/pydev_ipython/inputhook.py", line 502, in enable_gui
gui_hook = guis[gui]
KeyError: 'qt5'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/pycharm-2016.2.3/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 123, in enable_gui
return real_enable_gui(gui, app)
File "/opt/pycharm-2016.2.3/helpers/pydev/pydev_ipython/inputhook.py", line 508, in enable_gui
raise ValueError(e)
ValueError: Invalid GUI request 'qt5', valid ones are:dict_keys(['gtk3', 'wx', 'qt', 'osx', 'pyglet', 'glut', 'tk', 'gtk', 'none', 'qt4'])
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/foo/.conda/envs/myenv3/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2869, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-eff513f636fd>", line 1, in <module>
import matplotlib.pyplot as plt
ipython
时才会出现此问题。 但是,当我没有选择ipython时,我只会在plt.figure()
时遇到反应迟钝的黑屏。ipython
时,不会发生此问题。另外,如果我在导入matplotlib.use('Qt5Agg')
之前pyplot
,则错误会在pycharm中保留,但不会出现在我的终端的ipython控制台中。conda create -n test python=3.5 ; conda install ipython matplotlib scipy -n test
之后安装新的conda环境并在pycharm中加载新环境无济于事我怎样才能让它发挥作用?
答案 0 :(得分:8)
答案 1 :(得分:0)
作为替代方案,您可以按照http://matplotlib.org/users/customizing.html
中的报告配置matplotlibrc 在Linux上该文件应该放在.config / matplotlib / matplotlibrc
中刚设置:
backend : qt4Agg
这解决了我的问题。
答案 2 :(得分:0)
在select to_char( start_of_week, 'day dd.mm.yyyy' ) start_of_week,
to_char( start_of_week + 6, 'day dd.mm.yyyy' ) end_of_week
from
(
select trunc( date '2017-01-01' + 38*7 , 'day') start_of_week
from dual
)
中将D:\PyCharm Community Edition 2016.1.4\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py
的默认值从gui
更改为None
:
qt4