python-3.x - plotnine:UserWarning:在主线程之外启动 Matplotlib GUI 可能会失败

标签 python-3.x pycharm plotnine

我正在尝试使用 plotnine 生成一些图表。我导入所需的库:

from plotnine import *
from plotnine.data import mpg

然后,如果我在 PyCharm 中运行以下代码,我会收到一条警告消息,窗口图 显示“无应答”消息,我被迫重新启动 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 issuethis JetBrains issue ,看起来它可能与 PyCharm 错误有关。

关于python-3.x - plotnine:UserWarning:在主线程之外启动 Matplotlib GUI 可能会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64066186/

相关文章:

python - python中的计算器问题

python - argparse 函数参数

python - 使用 plotnine 保存高分辨率图像

ggplot2 - ggplot aes : color vs group with time series data missing

python - 在plotnine中使用 `scale_size_manual`时出现问题

Python 正则表达式 findall 匹配所有单词对

python - 如何将 Stellarium 生成的文件的二进制编码文件转换为 ASCII

eclipse - 在 pycharm 或 eclipse+pydev 的 C 线程中无法使用 python 断点

python - 如何在 PyCharm for Python 项目中获取代码覆盖率报告

python - 使用 matplotlib 绘图时如何避免 PyCharm 控制台崩溃 "WARNING: QApplication was not created in the main() thread"?