问题描述
我正在尝试使用橡皮糖生成一些图形。我导入所需的库:
from plotnine import *
from plotnine.data import mpg
然后,如果我在PyCharm中运行以下代码 ,我会收到警告消息,即窗口图 显示“ No answer”消息,我被迫重新启动python终端:
(ggplot(mpg) # defining what data to use
+ aes(x='class') # defining what variable to use
+ geom_bar(size=20) # defining the type of plot to use
)
<ggplot: (150517199824)>
C:\Users\alvaromc317\miniconda3\envs\general\lib\site-packages\plotnine\ggplot.py:363: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
但是,如果我从Windows cmd终端启动python终端并运行与以前相同的脚本,则不会收到错误消息,并且可以看到该图。
正在发生什么,如何在pycharm中使用plotnine?
如果需要的话,我使用Windows 10计算机和基于miniconda的python 3x。
解决方法
我遇到了类似的问题,但是在MacOS上使用了PyCharm的商业添加。
从this github issue和this JetBrains issue看来,它可能与PyCharm错误有关。