matplotlib not plotting in pycharm pro 2018.2 Follow
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?
Please sign in to leave a comment.
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.
I am also having this problem. None of the suggestions on this site or StackOverflow work. Can anyone at Jet Brains look into this?
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.
1) I have similar exact issues with matplotlib and seaborn. I have python 3.7 and latest version of pycharm
--- I can add screenshots of all if its too verbose ----
2) I tried to roll back for matplotlib 2.1.2 and I still get errors via settings/interpreter/+
these are download errors in event log:
executed command:
D:\anaconda3\Scripts\conda.exe install -p D:/anaconda3/envs/tf-1_937 matplotlib==2.1.2 -y
LinkError: post-link script failed for package defaults::qt-5.6.2-vc14h6f8c307_12
running your command again with `-v` will provide additional information
location of failed script: D:\anaconda3\envs\tf-1_937\Scripts\.qt-post-link.bat
==> script messages <==
<None>
Attempting to roll back.
ERROR conda.core.link:_execute(568): An error occurred while installing package 'defaults::qt-5.6.2-vc14h6f8c307_12'.
LinkError: post-link script failed for package defaults::qt-5.6.2-vc14h6f8c307_12
running your command again with `-v` will provide additional information
location of failed script: D:\anaconda3\envs\tf-1_937\Scripts\.qt-post-link.bat
==> script messages <==
<None>
3) oddly, it'll say it's downloaded, but once I try to make some code and run, I get failed errrors.
the errors are as follows:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-826ca185faee> in <module> ----> 1 import matplotlib.plyplot as plt 2 import seaborn as sns 3 get_ipython().run_line_magic('matplotlib', 'inline')
d:\anaconda3\envs\tf-1_937\lib\site-packages\matplotlib\__init__.py in <module> 126 _backports, mplDeprecation, dedent, get_label, sanitize_sequence) 127 from matplotlib.compat import subprocess --> 128 from matplotlib.rcsetup import defaultParams, validate_backend, cycler 129 130 import numpy
d:\anaconda3\envs\tf-1_937\lib\site-packages\matplotlib\rcsetup.py in <module> 27 28 from matplotlib.cbook import mplDeprecation, deprecated, ls_mapper ---> 29 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern 30 from matplotlib.colors import is_color_like 31
d:\anaconda3\envs\tf-1_937\lib\site-packages\matplotlib\fontconfig_pattern.py in <module> 24 import re 25 import sys ---> 26 from pyparsing import (Literal, ZeroOrMore, Optional, Regex, StringEnd, 27 ParseException, Suppress) 28
ModuleNotFoundError: No module named 'pyparsing'
4) here are my errors trying to install rollbacks in terminal
conda install matplotlib=2.1.2 -v
Traceback (most recent call last):
File "D:\anaconda3\lib\site-packages\conda\exceptions.py", line 1003, in __call__
return func(*args, **kwargs)
File "D:\anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
exit_code = do_call(args, p)
File "D:\anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 82, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "D:\anaconda3\lib\site-packages\conda\cli\main_install.py", line 20, in execute
install(args, parser, 'install')
File "D:\anaconda3\lib\site-packages\conda\cli\install.py", line 275, in install
handle_txn(unlink_link_transaction, prefix, args, newenv)
File "D:\anaconda3\lib\site-packages\conda\cli\install.py", line 304, in handle_txn
unlink_link_transaction.execute()
File "D:\anaconda3\lib\site-packages\conda\core\link.py", line 241, in execute
self._execute(tuple(concat(interleave(itervalues(self.pref
ix_action_groups)))))
File "D:\anaconda3\lib\site-packages\conda\core\link.py", li
ne 587, in _execute
rollback_excs,
conda.CondaMultiError: post-link script failed for package defaults::qt-5.6.2-vc14h6f8c307_12
running your command again with `-v` will provide additional information
location of failed script: D:\anaconda3\envs\tf-1_937\Scripts\.qt-post-link.bat
Hi Rzarate,
It doesn't look like a PyCharm related issue since the same problem is shown in the command line.