Can't import matplotlib


#1

Python: When I try and import matplotlib I get a ‘no module named matplotlib’ error.

Have searched but cannot find a fix that works (have tried apt-get which tells me it is installed)

numpy imports OK.

Any suggestions?


#2

You’ve probably created a Python environment, but what else have you installed so far?


#3

A couple of things to check out,

Make sure (I know this sounds stupid) that you aren’t working in a virtual environment. I know some people do this just out of habit and forget they are in one. apt-get will tell you globally installed python packages, but if you are working in a virtual environment, you will only have the standard library installed. So run pip freeze just to make sure that matplotlib is actually installed.

If that doesn’t work, check your site-packages file, usually located somewhere within /usr/bin/.local/ but you can run
the command: ~$ python -m site --user – user-site

that will tell you where your site packages are located. That’s usually how i start to look through things to see if everything is where it should be