Home > Software engineering >  Python matplotlib code hangs on plt.plot()
Python matplotlib code hangs on plt.plot()

Time:11-21

When I try to use certain functions from matplotlib, my code gets stuck at those functions. For example, if I try to run

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

It succesfully runs plt.figure(), but the execution of the code gets stuck at plt.plot(x, y). No error codes are produced, and I can't interrupt execution using ctrl c.

I work on Linux Mint 5.4.0-70-generic and I use miniconda for my python installation. I have python3.9 installed with the newest matplotlib and numpy packages. I already completely re-installed conda and python using tsveti_iko's answer (my previous version was python3.8, which gave the exact same issue). Up until today, everything worked perfectly.

EDIT: The only thing that I did before it stopped working is that I updated my os using apt-get update & apt-get upgrade. But I don't know if this could cause my above issue.

If I use

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

I get the following 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.

CodePudding user response:

This was indeed a very specific problem. For my work I needed to install the citrix workspace. Somehow this interfered with matplotlib. Uninstalling the citrix client completely solved the problem.

  • Related