2

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.
3
  • What IDE/program are you using? This is purely anecdotal but I had something similar happen a while ago with PyCharm and the PyQt5 plugin. Unfortunately i don't remember what the magic bullet was but if no one has a better idea then maybe check that out Commented Nov 17, 2021 at 22:30
  • @havingaball I just use atom as my text editor, and execute my code in the terminal. Commented Nov 18, 2021 at 7:35
  • @john-hen, it is indeed really the plot call that hangs. I added the output of logging to the question. Commented Nov 18, 2021 at 7:39

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Have you reported this as a bug at matplotlib? If not, please do so. They are able to help you out further and in the process gain knowledge for bugfixes. End of Review.
same issue on Ubuntu 22.04.4 LTS, solved on uninstalling citrix...how do you even realize the issue?
0

I don't know why but plt.show(block=True) helped for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.