簡體   English   中英

Python matplotlib 代碼掛在 plt.plot()

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

當我嘗試使用 matplotlib 中的某些函數時,我的代碼會卡在這些函數上。 例如,如果我嘗試運行

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()

它成功運行 plt.figure(),但代碼的執行卡在 plt.plot(x, y)。 沒有產生錯誤代碼,我不能使用 ctrl+c 中斷執行。

我在 Linux Mint 5.4.0-70-generic 上工作,我使用 miniconda 進行 python 安裝。 我安裝了帶有最新 matplotlib 和 numpy 包的 python3.9。 我已經使用 tsveti_iko 的答案完全重新安裝了 conda 和 python(我以前的版本是 python3.8,它給出了完全相同的問題)。 直到今天,一切都很完美。

編輯:在它停止工作之前我唯一做的就是我使用 apt-get update 和 apt-get upgrade 更新了我的操作系統。 但我不知道這是否會導致我的上述問題。

如果我使用

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

我得到以下 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.

這確實是一個非常具體的問題。 對於我的工作,我需要安裝citrix workspace 不知何故,這干擾了 matplotlib。 卸載 citrix 客戶端完全解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM