Python: matplotlib.pyplot.show() 没有显示情节
Python: matplotlib.pyplot.show() is not showing the plot
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
input("Press enter to continue...")
如果我在 VS Code 中 运行 上面的脚本,甚至在命令提示符中,绘图 canvas 只会闪烁几分之一秒,程序结束时不会出现任何错误。它甚至不等待按下 Enter。
可能很有趣:
- 当我第一次安装 Miniconda 并设置环境时,它成功了。然后我安装
pydicom
我成功 运行 测试脚本(带有pydicom测试图像)。当我尝试处理我自己的 DICOM 时,它需要 jpeg 解码器等。我安装了它们,还有其他我不记得的。从某个时候开始,它开始表现得像描述的那样。
- 我试图回滚到修订版本我知道它有效
conda install --revision XX
,但是产生了一个错误
- 我删除了环境
conda remove --name myenv --all
并从头开始创建它
- 我删除了环境并卸载了Miniconda,并重做了一切
问题依旧。
可能是什么原因?我该如何调试呢?有没有错误日志?
环境包:
_tflow_select 2.3.0 mkl anaconda
absl-py 0.10.0 py38_0 anaconda
aiohttp 3.6.3 py38he774522_0 anaconda
argon2-cffi 20.1.0 py38h2bbff1b_1
astunparse 1.6.3 py_0 anaconda
async-timeout 3.0.1 py38_0 anaconda
async_generator 1.10 pyhd3eb1b0_0
attrs 21.2.0 pyhd3eb1b0_0
backcall 0.2.0 pyhd3eb1b0_0
bayesian-optimization 1.2.0 pypi_0 pypi
blas 1.0 mkl anaconda
bleach 4.0.0 pyhd3eb1b0_0
blinker 1.4 py38_0 anaconda
boto3 1.18.21 pyhd3eb1b0_0
botocore 1.21.41 pyhd3eb1b0_1
brotli 1.0.9 ha925a31_2
brotlipy 0.7.0 py38he774522_1000 anaconda
ca-certificates 2021.10.26 haa95532_2
cachetools 4.1.1 py_0 anaconda
certifi 2021.10.8 py38haa95532_0
cffi 1.14.6 py38h2bbff1b_0
chardet 3.0.4 py38_1003 anaconda
charset-normalizer 2.0.4 pyhd3eb1b0_0
click 7.1.2 py_0 anaconda
cloudpickle 2.0.0 pypi_0 pypi
colorama 0.4.4 pyhd3eb1b0_0
cryptography 3.1.1 py38h7a1dbc1_0 anaconda
cycler 0.10.0 py38_0
daal4py 2021.3.0 py38h757b272_0
dal 2021.3.0 haa95532_564
debugpy 1.4.1 py38hd77b12b_0
decorator 5.1.0 pyhd3eb1b0_0
defusedxml 0.7.1 pyhd3eb1b0_0
entrypoints 0.3 py38_0
flask 1.1.2 pyhd3eb1b0_0
fonttools 4.25.0 pyhd3eb1b0_0
freetype 2.11.0 ha860e81_0
gast 0.4.0 py_0 anaconda
google-auth 1.22.1 py_0 anaconda
google-auth-oauthlib 0.4.1 py_2 anaconda
google-pasta 0.2.0 py_0 anaconda
grpcio 1.31.0 py38he7da953_0 anaconda
gym 0.21.0 pypi_0 pypi
h5py 2.10.0 py38h5e291fa_0
hdf5 1.10.4 h7ebc959_0 anaconda
icc_rt 2019.0.0 h0cc432a_1 anaconda
icu 58.2 ha925a31_3
idna 2.10 py_0 anaconda
importlib-metadata 4.8.1 py38haa95532_0
importlib_metadata 4.8.1 hd3eb1b0_0
intel-openmp 2020.2 254 anaconda
ipykernel 6.4.1 py38haa95532_1
ipython 7.27.0 py38hd4e2768_0
ipython_genutils 0.2.0 pyhd3eb1b0_1
ipywidgets 7.6.5 pyhd3eb1b0_1
itsdangerous 2.0.1 pyhd3eb1b0_0
jedi 0.18.0 py38haa95532_1
jinja2 3.0.2 pyhd3eb1b0_0
jmespath 0.10.0 pyhd3eb1b0_0
joblib 1.1.0 pyhd3eb1b0_0
jpeg 9d h2bbff1b_0
jsonschema 3.2.0 pyhd3eb1b0_2
jupyter 1.0.0 py38_7
jupyter_client 7.0.1 pyhd3eb1b0_0
jupyter_console 6.4.0 pyhd3eb1b0_0
jupyter_core 4.8.1 py38haa95532_0
jupyterlab_pygments 0.1.2 py_0
jupyterlab_widgets 1.0.0 pyhd3eb1b0_1
kaggle 1.5.12 pypi_0 pypi
keras-applications 1.0.8 py_1 anaconda
keras-preprocessing 1.1.0 py_1 anaconda
kiwisolver 1.3.1 py38hd77b12b_0
libiconv 1.15 h1df5818_7
libpng 1.6.37 h2a8f88b_0
libprotobuf 3.13.0.1 h200bbdf_0 anaconda
libtiff 4.2.0 hd0e1b90_0
libwebp 1.2.0 h2bbff1b_0
libxml2 2.9.12 h0ad7f3c_0
libxslt 1.1.34 he774522_0
lxml 4.6.3 py38h9b66d53_0
lz4-c 1.9.3 h2bbff1b_1
m2w64-gcc-libgfortran 5.3.0 6
m2w64-gcc-libs 5.3.0 7
m2w64-gcc-libs-core 5.3.0 7
m2w64-gmp 6.1.0 2
m2w64-libwinpthread-git 5.0.0.4634.697f757 2
markdown 3.3.2 py38_0 anaconda
markupsafe 2.0.1 py38h2bbff1b_0
matplotlib 3.4.3 py38haa95532_0
matplotlib-base 3.4.3 py38h49ac443_0
matplotlib-inline 0.1.2 pyhd3eb1b0_2
mistune 0.8.4 py38he774522_1000
mkl 2019.4 245 anaconda
mkl-service 2.3.0 py38hb782905_0 anaconda
mkl_fft 1.2.0 py38h45dec08_0 anaconda
mkl_random 1.1.0 py38hf9181ef_0 anaconda
msys2-conda-epoch 20160418 1
multidict 4.7.6 py38he774522_1 anaconda
munkres 1.1.4 py_0
nb_conda 2.2.1 py38_1
nb_conda_kernels 2.3.1 py38haa95532_0
nbclient 0.5.3 pyhd3eb1b0_0
nbconvert 6.1.0 py38haa95532_0
nbformat 5.1.3 pyhd3eb1b0_0
nest-asyncio 1.5.1 pyhd3eb1b0_0
notebook 6.4.5 py38haa95532_0
numpy 1.19.1 py38h5510c5b_0 anaconda
numpy-base 1.19.1 py38ha3acd2a_0 anaconda
oauthlib 3.1.0 py_0 anaconda
olefile 0.46 pyhd3eb1b0_0
openssl 1.1.1l h2bbff1b_0
opt_einsum 3.1.0 py_0 anaconda
packaging 21.0 pyhd3eb1b0_0
pandas 1.2.4 py38hf11a4ad_0
pandas-datareader 0.10.0 pyhd3eb1b0_0
pandocfilters 1.4.3 py38haa95532_1
parso 0.8.2 pyhd3eb1b0_0
pickleshare 0.7.5 pyhd3eb1b0_1003
pillow 8.4.0 py38hd45dc43_0
pip 21.2.2 py38haa95532_0
prometheus_client 0.11.0 pyhd3eb1b0_0
prompt-toolkit 3.0.20 pyhd3eb1b0_0
prompt_toolkit 3.0.20 hd3eb1b0_0
protobuf 3.13.0.1 py38ha925a31_1 anaconda
pyasn1 0.4.8 py_0 anaconda
pyasn1-modules 0.2.8 py_0 anaconda
pycparser 2.20 py_2
pygments 2.10.0 pyhd3eb1b0_0
pyjwt 1.7.1 py38_0 anaconda
pyopenssl 19.1.0 py_1 anaconda
pyparsing 3.0.4 pyhd3eb1b0_0
pyqt 5.9.2 py38ha925a31_4
pyreadline 2.1 py38_1 anaconda
pyrsistent 0.17.3 py38he774522_0
pysocks 1.7.1 py38_0 anaconda
python 3.8.12 h6244533_0
python-dateutil 2.8.2 pyhd3eb1b0_0
python-slugify 5.0.2 pypi_0 pypi
pytz 2021.3 pyhd3eb1b0_0
pywin32 228 py38hbaba5e8_1
pywinpty 0.5.7 py38_0
pyyaml 6.0 py38h2bbff1b_1
pyzmq 22.2.1 py38hd77b12b_1
qt 5.9.7 vc14h73c81de_0
qtconsole 5.1.1 pyhd3eb1b0_0
qtpy 1.10.0 pyhd3eb1b0_0
requests 2.26.0 pyhd3eb1b0_0
requests-oauthlib 1.3.0 py_0 anaconda
rsa 4.6 py_0 anaconda
s3transfer 0.5.0 pyhd3eb1b0_0
scikit-learn 1.0.1 py38hf11a4ad_0
scikit-learn-intelex 2021.3.0 py38haa95532_0
scipy 1.6.2 py38h14eb087_0
send2trash 1.8.0 pyhd3eb1b0_1
setuptools 58.0.4 py38haa95532_0
sip 4.19.13 py38ha925a31_0
six 1.16.0 pyhd3eb1b0_0
sqlite 3.36.0 h2bbff1b_0
tbb 2021.4.0 h59b6b97_0
tensorboard 2.6.0 py_1
tensorboard-data-server 0.6.0 py38haa95532_0
tensorboard-plugin-wit 1.6.0 py_0 anaconda
tensorflow 2.3.0 mkl_py38h37f7ee5_0
tensorflow-base 2.3.0 eigen_py38h75a453f_0
tensorflow-estimator 2.3.0 pyheb71bc4_0 anaconda
termcolor 1.1.0 py38_1 anaconda
terminado 0.9.4 py38haa95532_0
testpath 0.5.0 pyhd3eb1b0_0
text-unidecode 1.3 pypi_0 pypi
threadpoolctl 2.2.0 pyh0d69192_0
tk 8.6.11 h2bbff1b_0
tornado 6.1 py38h2bbff1b_0
tqdm 4.62.3 pyhd3eb1b0_1
traitlets 5.1.0 pyhd3eb1b0_0
urllib3 1.25.11 py_0 anaconda
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wcwidth 0.2.5 pyhd3eb1b0_0
webencodings 0.5.1 py38_1
werkzeug 1.0.1 py_0 anaconda
wheel 0.37.0 pyhd3eb1b0_1
widgetsnbextension 3.5.1 py38_0
win_inet_pton 1.1.0 py38_0 anaconda
wincertstore 0.2 py38haa95532_2
winpty 0.4.3 4
wrapt 1.12.1 py38he774522_1 anaconda
xz 5.2.5 h62dcd97_0
yaml 0.2.5 he774522_0
yarl 1.6.2 py38he774522_0 anaconda
zipp 3.6.0 pyhd3eb1b0_0
zlib 1.2.11 vc14h1cdd9ab_1 [vc14] anaconda
zstd 1.4.9 h19a0ad4_0
最近,conda 和 matplotlib
一直有问题。
您可以通过 conda install freetype=2.10.4
尝试将 freetype 从 2.11.0 降级到 2.10.4
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
input("Press enter to continue...")
如果我在 VS Code 中 运行 上面的脚本,甚至在命令提示符中,绘图 canvas 只会闪烁几分之一秒,程序结束时不会出现任何错误。它甚至不等待按下 Enter。
可能很有趣:
- 当我第一次安装 Miniconda 并设置环境时,它成功了。然后我安装
pydicom
我成功 运行 测试脚本(带有pydicom测试图像)。当我尝试处理我自己的 DICOM 时,它需要 jpeg 解码器等。我安装了它们,还有其他我不记得的。从某个时候开始,它开始表现得像描述的那样。 - 我试图回滚到修订版本我知道它有效
conda install --revision XX
,但是产生了一个错误 - 我删除了环境
conda remove --name myenv --all
并从头开始创建它 - 我删除了环境并卸载了Miniconda,并重做了一切
问题依旧。
可能是什么原因?我该如何调试呢?有没有错误日志?
环境包:
_tflow_select 2.3.0 mkl anaconda
absl-py 0.10.0 py38_0 anaconda
aiohttp 3.6.3 py38he774522_0 anaconda
argon2-cffi 20.1.0 py38h2bbff1b_1
astunparse 1.6.3 py_0 anaconda
async-timeout 3.0.1 py38_0 anaconda
async_generator 1.10 pyhd3eb1b0_0
attrs 21.2.0 pyhd3eb1b0_0
backcall 0.2.0 pyhd3eb1b0_0
bayesian-optimization 1.2.0 pypi_0 pypi
blas 1.0 mkl anaconda
bleach 4.0.0 pyhd3eb1b0_0
blinker 1.4 py38_0 anaconda
boto3 1.18.21 pyhd3eb1b0_0
botocore 1.21.41 pyhd3eb1b0_1
brotli 1.0.9 ha925a31_2
brotlipy 0.7.0 py38he774522_1000 anaconda
ca-certificates 2021.10.26 haa95532_2
cachetools 4.1.1 py_0 anaconda
certifi 2021.10.8 py38haa95532_0
cffi 1.14.6 py38h2bbff1b_0
chardet 3.0.4 py38_1003 anaconda
charset-normalizer 2.0.4 pyhd3eb1b0_0
click 7.1.2 py_0 anaconda
cloudpickle 2.0.0 pypi_0 pypi
colorama 0.4.4 pyhd3eb1b0_0
cryptography 3.1.1 py38h7a1dbc1_0 anaconda
cycler 0.10.0 py38_0
daal4py 2021.3.0 py38h757b272_0
dal 2021.3.0 haa95532_564
debugpy 1.4.1 py38hd77b12b_0
decorator 5.1.0 pyhd3eb1b0_0
defusedxml 0.7.1 pyhd3eb1b0_0
entrypoints 0.3 py38_0
flask 1.1.2 pyhd3eb1b0_0
fonttools 4.25.0 pyhd3eb1b0_0
freetype 2.11.0 ha860e81_0
gast 0.4.0 py_0 anaconda
google-auth 1.22.1 py_0 anaconda
google-auth-oauthlib 0.4.1 py_2 anaconda
google-pasta 0.2.0 py_0 anaconda
grpcio 1.31.0 py38he7da953_0 anaconda
gym 0.21.0 pypi_0 pypi
h5py 2.10.0 py38h5e291fa_0
hdf5 1.10.4 h7ebc959_0 anaconda
icc_rt 2019.0.0 h0cc432a_1 anaconda
icu 58.2 ha925a31_3
idna 2.10 py_0 anaconda
importlib-metadata 4.8.1 py38haa95532_0
importlib_metadata 4.8.1 hd3eb1b0_0
intel-openmp 2020.2 254 anaconda
ipykernel 6.4.1 py38haa95532_1
ipython 7.27.0 py38hd4e2768_0
ipython_genutils 0.2.0 pyhd3eb1b0_1
ipywidgets 7.6.5 pyhd3eb1b0_1
itsdangerous 2.0.1 pyhd3eb1b0_0
jedi 0.18.0 py38haa95532_1
jinja2 3.0.2 pyhd3eb1b0_0
jmespath 0.10.0 pyhd3eb1b0_0
joblib 1.1.0 pyhd3eb1b0_0
jpeg 9d h2bbff1b_0
jsonschema 3.2.0 pyhd3eb1b0_2
jupyter 1.0.0 py38_7
jupyter_client 7.0.1 pyhd3eb1b0_0
jupyter_console 6.4.0 pyhd3eb1b0_0
jupyter_core 4.8.1 py38haa95532_0
jupyterlab_pygments 0.1.2 py_0
jupyterlab_widgets 1.0.0 pyhd3eb1b0_1
kaggle 1.5.12 pypi_0 pypi
keras-applications 1.0.8 py_1 anaconda
keras-preprocessing 1.1.0 py_1 anaconda
kiwisolver 1.3.1 py38hd77b12b_0
libiconv 1.15 h1df5818_7
libpng 1.6.37 h2a8f88b_0
libprotobuf 3.13.0.1 h200bbdf_0 anaconda
libtiff 4.2.0 hd0e1b90_0
libwebp 1.2.0 h2bbff1b_0
libxml2 2.9.12 h0ad7f3c_0
libxslt 1.1.34 he774522_0
lxml 4.6.3 py38h9b66d53_0
lz4-c 1.9.3 h2bbff1b_1
m2w64-gcc-libgfortran 5.3.0 6
m2w64-gcc-libs 5.3.0 7
m2w64-gcc-libs-core 5.3.0 7
m2w64-gmp 6.1.0 2
m2w64-libwinpthread-git 5.0.0.4634.697f757 2
markdown 3.3.2 py38_0 anaconda
markupsafe 2.0.1 py38h2bbff1b_0
matplotlib 3.4.3 py38haa95532_0
matplotlib-base 3.4.3 py38h49ac443_0
matplotlib-inline 0.1.2 pyhd3eb1b0_2
mistune 0.8.4 py38he774522_1000
mkl 2019.4 245 anaconda
mkl-service 2.3.0 py38hb782905_0 anaconda
mkl_fft 1.2.0 py38h45dec08_0 anaconda
mkl_random 1.1.0 py38hf9181ef_0 anaconda
msys2-conda-epoch 20160418 1
multidict 4.7.6 py38he774522_1 anaconda
munkres 1.1.4 py_0
nb_conda 2.2.1 py38_1
nb_conda_kernels 2.3.1 py38haa95532_0
nbclient 0.5.3 pyhd3eb1b0_0
nbconvert 6.1.0 py38haa95532_0
nbformat 5.1.3 pyhd3eb1b0_0
nest-asyncio 1.5.1 pyhd3eb1b0_0
notebook 6.4.5 py38haa95532_0
numpy 1.19.1 py38h5510c5b_0 anaconda
numpy-base 1.19.1 py38ha3acd2a_0 anaconda
oauthlib 3.1.0 py_0 anaconda
olefile 0.46 pyhd3eb1b0_0
openssl 1.1.1l h2bbff1b_0
opt_einsum 3.1.0 py_0 anaconda
packaging 21.0 pyhd3eb1b0_0
pandas 1.2.4 py38hf11a4ad_0
pandas-datareader 0.10.0 pyhd3eb1b0_0
pandocfilters 1.4.3 py38haa95532_1
parso 0.8.2 pyhd3eb1b0_0
pickleshare 0.7.5 pyhd3eb1b0_1003
pillow 8.4.0 py38hd45dc43_0
pip 21.2.2 py38haa95532_0
prometheus_client 0.11.0 pyhd3eb1b0_0
prompt-toolkit 3.0.20 pyhd3eb1b0_0
prompt_toolkit 3.0.20 hd3eb1b0_0
protobuf 3.13.0.1 py38ha925a31_1 anaconda
pyasn1 0.4.8 py_0 anaconda
pyasn1-modules 0.2.8 py_0 anaconda
pycparser 2.20 py_2
pygments 2.10.0 pyhd3eb1b0_0
pyjwt 1.7.1 py38_0 anaconda
pyopenssl 19.1.0 py_1 anaconda
pyparsing 3.0.4 pyhd3eb1b0_0
pyqt 5.9.2 py38ha925a31_4
pyreadline 2.1 py38_1 anaconda
pyrsistent 0.17.3 py38he774522_0
pysocks 1.7.1 py38_0 anaconda
python 3.8.12 h6244533_0
python-dateutil 2.8.2 pyhd3eb1b0_0
python-slugify 5.0.2 pypi_0 pypi
pytz 2021.3 pyhd3eb1b0_0
pywin32 228 py38hbaba5e8_1
pywinpty 0.5.7 py38_0
pyyaml 6.0 py38h2bbff1b_1
pyzmq 22.2.1 py38hd77b12b_1
qt 5.9.7 vc14h73c81de_0
qtconsole 5.1.1 pyhd3eb1b0_0
qtpy 1.10.0 pyhd3eb1b0_0
requests 2.26.0 pyhd3eb1b0_0
requests-oauthlib 1.3.0 py_0 anaconda
rsa 4.6 py_0 anaconda
s3transfer 0.5.0 pyhd3eb1b0_0
scikit-learn 1.0.1 py38hf11a4ad_0
scikit-learn-intelex 2021.3.0 py38haa95532_0
scipy 1.6.2 py38h14eb087_0
send2trash 1.8.0 pyhd3eb1b0_1
setuptools 58.0.4 py38haa95532_0
sip 4.19.13 py38ha925a31_0
six 1.16.0 pyhd3eb1b0_0
sqlite 3.36.0 h2bbff1b_0
tbb 2021.4.0 h59b6b97_0
tensorboard 2.6.0 py_1
tensorboard-data-server 0.6.0 py38haa95532_0
tensorboard-plugin-wit 1.6.0 py_0 anaconda
tensorflow 2.3.0 mkl_py38h37f7ee5_0
tensorflow-base 2.3.0 eigen_py38h75a453f_0
tensorflow-estimator 2.3.0 pyheb71bc4_0 anaconda
termcolor 1.1.0 py38_1 anaconda
terminado 0.9.4 py38haa95532_0
testpath 0.5.0 pyhd3eb1b0_0
text-unidecode 1.3 pypi_0 pypi
threadpoolctl 2.2.0 pyh0d69192_0
tk 8.6.11 h2bbff1b_0
tornado 6.1 py38h2bbff1b_0
tqdm 4.62.3 pyhd3eb1b0_1
traitlets 5.1.0 pyhd3eb1b0_0
urllib3 1.25.11 py_0 anaconda
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wcwidth 0.2.5 pyhd3eb1b0_0
webencodings 0.5.1 py38_1
werkzeug 1.0.1 py_0 anaconda
wheel 0.37.0 pyhd3eb1b0_1
widgetsnbextension 3.5.1 py38_0
win_inet_pton 1.1.0 py38_0 anaconda
wincertstore 0.2 py38haa95532_2
winpty 0.4.3 4
wrapt 1.12.1 py38he774522_1 anaconda
xz 5.2.5 h62dcd97_0
yaml 0.2.5 he774522_0
yarl 1.6.2 py38he774522_0 anaconda
zipp 3.6.0 pyhd3eb1b0_0
zlib 1.2.11 vc14h1cdd9ab_1 [vc14] anaconda
zstd 1.4.9 h19a0ad4_0
最近,conda 和 matplotlib
一直有问题。
您可以通过 conda install freetype=2.10.4