ModuleNotFoundError: No module named 'matplotlib'

I am trying to learn a little about Python (3.8.1).  I'm really a beginner although I have some ancient programming experience.

I am currently trying to install matplotlib.  I have used pip and it seems to declare victory, i.e. if I try to install it again or install it in a different directory the command prompt box tells me "Requirement already satisfied" ... I get the same thing if I try to upgrade it too.

I opened the python shell (IDLE) and typed in:

from matplotlib import pyplot
pyplot.axes()
pyplot.show()

This worked just fine. When I try it from Pycharm, I get: ModuleNotFoundError: No module named 'matplotlib'

I had a similar problem (for a while) trying to get pyglet running but that resolved itself somehow ... sadly it seems to have
just started to work.

I had to install pyglet in the python directory, so that is where I put matplotlib. No good. So I tried to install it with my
python projects but when I do that I get the "Requirement already satisfied" message.

How can I get python/PyCharm to find matplotlib like the python shell does.
 


11 comments
Comment actions Permalink

I see I made a rookie mistake in submitting my question

0
Comment actions Permalink

In PyCharm you could create a new project interpreter with a new virtual environment which is unaware of the packages from other/global environment.

Try to install matplotlib specifically for the current project interpreter: https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

0
Comment actions Permalink

I believe I just tried your suggestion:

 

I found the window with a list of packages and hit the + key to add one.

I had the resulting "available Packages" window search for matplotlib ... which it found.

I hit the Install package Button and it went to work installing but came back with  error messages.

Examining the details showed:

ModuleNotFoundErrror:  No Module named Cython

RunTimError: Runnning Cythonize failed

Command "python setup.py egg_info failed with error code 1 ....

 

??

0
Comment actions Permalink

>ModuleNotFoundErrror:  No Module named Cython

Try installing module Cython using the same procedure.

0
Comment actions Permalink

well, this is fun.

Installing Cython failed because I needed Visual C++ Build tools, so I installed those.  A system reset ws part of the instructions for the install. 

 

Then it said to:

pip install -- upgrade setuptools.  I did but I don't think it worked.  I don't know if that should be in the PyCharm folder or the Python folder or just the default CMD prompt folder.  I tried them all.  it "couldn't find a versions that satisfies the requirement upgrade."

 

after that failed every time I went back to try to install Cython but found it in the installed list.

 

so I tried to install matplotlib.

Eror occurred src/checkdep_freetype2.c(5):  fatal error c1189: #error:"FreeType version 2.3 or higher required.  You may set the 

MPLLOCALFREETYPE evironment variable to let Matplotlib download it.

 

I've got no idea what that is about

 

Thanks

0
Comment actions Permalink

You said in the beginning that running your script from the shell worked well. So, check which interpreter you are using there (e.g. using "where python" command) and configure this same interpreter in PyCharm. After it finishes with indexing, you should see matplotlib installed in the package list.

0
Comment actions Permalink

I tried the "where python" command in the Shell window but that gave:  SyntaxError: invalid syntax

I tried it in the cmd window and that gave me a path.

So, I have a path from the cmd window - which is different from what  Pycharm has been using, but I don't know how to configure it in PyCharm.  I went to the "settings" under the File menu in PyCharm and found the Python Interpreter area, but I saw no way to type in the path or to select the new path from the drop down list (the path wasn't there).  I tried several other things in the settings window but nothing would accept  a change.

 

Sorry to be a noob

0
Comment actions Permalink

Create the new interpreter according to https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html

Select "System interpreter" and use the one from that path.

0
Comment actions Permalink

Thank you.

I selected a Python Interpreter (python.exe, right?) in the "Select Python Interpreter" window and clicked "OK" which returned me to the "Add Python Interpreter" window.  The OK button in the "Add Python Interpreter" window nerver highlighted so I could not click OK and it did not work.  (This is one of the things I had tried earlier).

Still getting: ModuleNotFoundError: No module named 'matplotlib'

0
Comment actions Permalink

By the way I did it in both new environment and existing environment  The existing environment  process DID highlight the OK button but there was an "Error configuring SDK"

0
Comment actions Permalink

I get this from time to time as well, but always after an exception was thrown somewhere for some reason (different reasons for different projects). I don't know why but I end up destroying the venv and rebuilding it until it goes away....

#frustrating

 

0

Please sign in to leave a comment.