matplotlib not plotting in pycharm pro 2018.2

Answered

I have python 3.7 and pycharm pro 2018.2 running on Mac OSX (10.13.6). Everything is the latest and fully updated.

I create a new project, pure python, using system interpreter (/usr/local/bin/python3.7) or using venv (doesn't matter, the result is the same). Create a python file like this:

#!/usr/bin/env python3

import matplotlib.pyplot as plt
import numpy as np
import matplotlib

# Fixing random state for reproducibility
np.random.seed(19680801)


x = np.arange(0.0, 50.0, 2.0)
y = x ** 1.3 + np.random.rand(*x.shape) * 30.0
s = np.random.rand(*x.shape) * 800 + 500

plt.scatter(x, y, s, c="g", alpha=0.5, marker=r'$\clubsuit$',
label="Luck")
plt.xlabel("Leprechauns")
plt.ylabel("Gold")
plt.legend(loc=2)
plt.show()

Create a requirements.txt file with "matplotlib" in it, and install matplotlib.

Run the file (either run or debug in pycharm). It just starts and finishes instantly.

Go to a Terminal window and run it ./project.py and it works perfectly. (I had to chmod +x first). Displays the plot.

Why isn't this working in pycharm?

3 comments

I have the same problem.  However it works perfectly on one PC and fails in the way indicated on another.  I can't find any configuration difference that would cause this.

Interestingly, when I run the app using the debugger or the profiler, the plot appears in the plot window.  When I run the app normally, the plot does not appear.

 

1

I am also having this problem. None of the suggestions on this site or StackOverflow work. Can anyone at Jet Brains look into this?

0

Hi Jmcanal,

May I ask you to attach a screenshot of your Run/Debug Configuration and upload your renamed idea.log (Help | Show Log in...) to https://uploads.services.jetbrains.com/ and let me know the name of that file?

You could also use SUBMIT A REQUEST button on this page and attach it there, if you are worried about sensitive data.

0

Please sign in to leave a comment.