當我嘗試使用 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)
我得到以下輸出:
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.
uj5u.com熱心網友回復:
這確實是一個非常具體的問題。對于我的作業,我需要安裝 citrix 作業區。不知何故,這干擾了 matplotlib。卸載citrix客戶端徹底解決了問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/362639.html
標籤:Python matplotlib
下一篇:從另一個類呼叫受保護的變數
