python-3.x - plotnine:用户警告:在主线程之外启动 Matplotlib GUI 可能会失败
问题描述
我正在尝试使用 plotnine 生成一些图表。我导入所需的库:
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 工作。
解决方案
我遇到了类似的问题,但是在使用 PyCharm 的商业添加的 MacOS 上。
从这个 github 问题和这个 JetBrains 问题来看,它看起来可能与 PyCharm 错误有关。
推荐阅读
- reactjs - VSCode 键绑定导航到渲染方法
- flutter - Flutter:如何从 Uint8List 播放视频
- android - Android如何在api 24下以编程方式执行单击,长按和滑动操作(从左到右,从右到左,从下到上,从上到下)
- php - 上传文件名的PHP Laravel编码问题
- tensorflow - 带有 keras、tensorflow 的神经网络 InvalidArgumentError
- excel - 如何引用两个单独的范围?
- ansible - 仅更改文件的权限
- sql - 你能重写NVL函数吗?
- php - 时间戳字段按照我的本地时区存储,但在 laravel 中用 shift -3 小时检索
- nestjs-swagger - 我们如何使用 swagger/nestjs 在 API 文档中添加一些自定义错误(相关键)?