简体   繁体   English

Python matplotlib 代码挂在 plt.plot()

[英]Python matplotlib code hangs on plt.plot()

When I try to use certain functions from matplotlib, my code gets stuck at those functions.当我尝试使用 matplotlib 中的某些函数时,我的代码会卡在这些函数上。 For example, if I try to run例如,如果我尝试运行

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()

x = np.random.randint(0, 10, 10)
y = np.random.randint(0, 10, 10)

plt.plot(x, y)
plt.show()

It succesfully runs plt.figure(), but the execution of the code gets stuck at plt.plot(x, y).它成功运行 plt.figure(),但代码的执行卡在 plt.plot(x, y)。 No error codes are produced, and I can't interrupt execution using ctrl+c.没有产生错误代码,我不能使用 ctrl+c 中断执行。

I work on Linux Mint 5.4.0-70-generic and I use miniconda for my python installation.我在 Linux Mint 5.4.0-70-generic 上工作,我使用 miniconda 进行 python 安装。 I have python3.9 installed with the newest matplotlib and numpy packages.我安装了带有最新 matplotlib 和 numpy 包的 python3.9。 I already completely re-installed conda and python using tsveti_iko's answer (my previous version was python3.8, which gave the exact same issue).我已经使用 tsveti_iko 的答案完全重新安装了 conda 和 python(我以前的版本是 python3.8,它给出了完全相同的问题)。 Up until today, everything worked perfectly.直到今天,一切都很完美。

EDIT: The only thing that I did before it stopped working is that I updated my os using apt-get update & apt-get upgrade.编辑:在它停止工作之前我唯一做的就是我使用 apt-get update 和 apt-get upgrade 更新了我的操作系统。 But I don't know if this could cause my above issue.但我不知道这是否会导致我的上述问题。

If I use如果我使用

import logging
logging.basicConfig(level=logging.DEBUG)

I get the following output:我得到以下 output:

DEBUG:matplotlib:matplotlib data path: 
/home/sjoerd/miniconda3/lib/python3.9/site-packages/matplotlib/mpl-data
DEBUG:matplotlib:CONFIGDIR=/home/sjoerd/.config/matplotlib
DEBUG:matplotlib:matplotlib version 3.4.3
DEBUG:matplotlib:interactive is False
DEBUG:matplotlib:platform is linux
DEBUG:matplotlib:loaded modules: [(whole list of modules loaded, not shown here)]
DEBUG:matplotlib:CACHEDIR=/home/sjoerd/.cache/matplotlib
DEBUG:matplotlib.font_manager:Using fontManager instance from /home/sjoerd/.cache/matplotlib/fontlist-v330.json
DEBUG:matplotlib.pyplot:Loaded backend qt5agg version unknown.
DEBUG:matplotlib.pyplot:Loaded backend Qt5Agg version unknown.

This was indeed a very specific problem.这确实是一个非常具体的问题。 For my work I needed to install the citrix workspace .对于我的工作,我需要安装citrix workspace Somehow this interfered with matplotlib.不知何故,这干扰了 matplotlib。 Uninstalling the citrix client completely solved the problem.卸载 citrix 客户端完全解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM