'Matplotlib plots won't display with sublime text and conda

I have set up and activated conda virtual environment that I use in Sublime Text 3. I have installed matplotlib into my conda virtual environment. When I try to generate a simple plot with the Conda build system, no plot is displayed and the code finishes running. I've tried editing the "Conda (Windows).sublime-settings" file to set "run_through_shell" to true but that hasn't fixed the problem. I've also tried adding "shell": true to the "Preferences.sublime-settings" but that hasn't worked either.

Edit: Matplotlib will plot when I import torch, but not when I don't have torch imported. Is there a dependency that comes along with torch that allows plots to be displayed?

Edit2: Here is the output of conda list for my virtual env:

# packages in environment at C:\Users\noami\anaconda3\envs\practice:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl
brotli                    1.0.9                ha925a31_2
ca-certificates           2022.2.1             haa95532_0
certifi                   2021.10.8        py39haa95532_2
cudatoolkit               10.2.89              h74a9793_1
cycler                    0.11.0             pyhd3eb1b0_0
fonttools                 4.25.0             pyhd3eb1b0_0
freetype                  2.10.4               hd328e21_0
icu                       58.2                 ha925a31_3
intel-openmp              2021.4.0          haa95532_3556
jpeg                      9d                   h2bbff1b_0
kiwisolver                1.3.2            py39hd77b12b_0
libpng                    1.6.37               h2a8f88b_0
libtiff                   4.2.0                hd0e1b90_0
libuv                     1.40.0               he774522_0
libwebp                   1.2.2                h2bbff1b_0
lz4-c                     1.9.3                h2bbff1b_1
matplotlib                3.5.1            py39haa95532_0
matplotlib-base           3.5.1            py39hd77b12b_0
mkl                       2021.4.0           haa95532_640
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.5           py39ha4e8547_0
numpy-base                1.21.5           py39hc2deb75_0
olefile                   0.46               pyhd3eb1b0_0
openssl                   1.1.1m               h2bbff1b_0
packaging                 21.3               pyhd3eb1b0_0
pillow                    8.4.0            py39hd45dc43_0
pip                       21.2.4           py39haa95532_0
pyparsing                 3.0.4              pyhd3eb1b0_0
pyqt                      5.9.2            py39hd77b12b_6
python                    3.9.7                h6244533_1
python-dateutil           2.8.2              pyhd3eb1b0_0
pytorch                   1.10.2          py3.9_cuda10.2_cudnn7_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
qt                        5.9.7            vc14h73c81de_0
setuptools                58.0.4           py39haa95532_0
sip                       4.19.13          py39hd77b12b_0
six                       1.16.0             pyhd3eb1b0_1
sqlite                    3.37.2               h2bbff1b_0
tk                        8.6.11               h2bbff1b_0
torchaudio                0.10.2               py39_cu102    pytorch
torchvision               0.11.3               py39_cu102    pytorch
tornado                   6.1              py39h2bbff1b_0
typing_extensions         3.10.0.2           pyh06a4308_0
tzdata                    2021e                hda174b7_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.37.1             pyhd3eb1b0_0
wincertstore              0.2              py39haa95532_2
xz                        5.2.5                h62dcd97_0
zlib                      1.2.11               h8cc25b3_4
zstd                      1.4.9                h19a0ad4_0

When I run this code, I don't get a plot:

import matplotlib.pyplot as plt

plt.plot([1,2,3,4,5])
plt.show()

print("Done!")

However when I run this code, I DO get a plot:

import matplotlib.pyplot as plt
import torch

plt.plot([1,2,3,4,5])
plt.show()

print("Done!")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source