0

In the base environment on Anaconda, plt.show() works fine and the graph is displayed.

(base) c:\work>python
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x00000214DCED9100>]
>>> plt.show()
>>>

I have created a new environment and install matplotlib. In this environment, when I use plt.show(), a black window appears for a moment and then disappears and the graph is not displayed. The python environment also shuts down by itself.

(base) c:\work>conda create -n plot matplotlib
(base) c:\work>conda activate plot
(plot) c:\work>python
Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x00000227A0049BB0>]
>>> plt.show()

(plot) c:\work>

Is there any solution for this?

The OS is windows 10. The conda list is shown here

# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: win-64
blas=1.0=mkl
brotli=1.0.9=ha925a31_2
ca-certificates=2021.10.26=haa95532_2
certifi=2021.10.8=py39haa95532_0
cycler=0.10.0=py39haa95532_0
fonttools=4.25.0=pyhd3eb1b0_0
freetype=2.11.0=ha860e81_0
icu=58.2=ha925a31_3
intel-openmp=2021.3.0=haa95532_3372
jpeg=9d=h2bbff1b_0
kiwisolver=1.3.1=py39hd77b12b_0
libpng=1.6.37=h2a8f88b_0
libtiff=4.2.0=hd0e1b90_0
libwebp=1.2.0=h2bbff1b_0
lz4-c=1.9.3=h2bbff1b_1
matplotlib=3.4.3=py39haa95532_0
matplotlib-base=3.4.3=py39h49ac443_0
mkl=2021.3.0=haa95532_524
mkl-service=2.4.0=py39h2bbff1b_0
mkl_fft=1.3.1=py39h277e83a_0
mkl_random=1.2.2=py39hf11a4ad_0
munkres=1.1.4=py_0
numpy=1.21.2=py39hfca59bb_0
numpy-base=1.21.2=py39h0829f74_0
olefile=0.46=pyhd3eb1b0_0
openssl=1.1.1l=h2bbff1b_0
pillow=8.4.0=py39hd45dc43_0
pip=21.2.4=py39haa95532_0
pyparsing=2.4.7=pyhd3eb1b0_0
pyqt=5.9.2=py39hd77b12b_6
python=3.9.7=h6244533_1
python-dateutil=2.8.2=pyhd3eb1b0_0
qt=5.9.7=vc14h73c81de_0
setuptools=58.0.4=py39haa95532_0
sip=4.19.13=py39hd77b12b_0
six=1.16.0=pyhd3eb1b0_0
sqlite=3.36.0=h2bbff1b_0
tk=8.6.10=he774522_0
tornado=6.1=py39h2bbff1b_0
tzdata=2021e=hda174b7_0
vc=14.2=h21ff451_1
vs2015_runtime=14.27.29016=h5e58377_2
wheel=0.37.0=pyhd3eb1b0_1
wincertstore=0.2=py39haa95532_2
xz=5.2.5=h62dcd97_0
zlib=1.2.11=h62dcd97_4
zstd=1.4.9=h19a0ad4_0
SolKul
  • 21
  • 3
  • Does this answer your question? [After conda update, python kernel crashes when matplotlib is used](https://stackoverflow.com/q/69786885/7758804) – Trenton McKinney Nov 01 '21 at 04:23
  • 1
    Thank you very much! Downgrading `freetype` solved the problem! (I actually spent a day yesterday reinstalling anaconda 5 times because of this bug.) – SolKul Nov 01 '21 at 04:53
  • You're welcome, and Me too! I spent about 6 hours working on the stupid issue on Saturday. There wasn't a bug report then, I checked. I had already removed Anaconda, before thinking to get a revision report from conda. I had to hook up a computer with fewer updates than a clean installation, to dig through to find the issue. – Trenton McKinney Nov 01 '21 at 04:54

1 Answers1

0

As you can see in the first base env, it works because it is on python 3.8, python 3.8 can work with matplotlib.

In the second one you are using python 3.9, while at the moment matplotlib is having a lot of failures with python 3.9, you should right now use only python 3.8.

You can see what I'm talking about in here, people is having issues while using python 3.9+

Bernardo Olisan
  • 665
  • 7
  • 20