Python Forum
matplotlib isn't recognized after installation - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: matplotlib isn't recognized after installation (/thread-21189.html)



matplotlib isn't recognized after installation - Pavel_47 - Sep-18-2019

Hello,

I've installed matplotlib using the following command:
python -m pip install matplotlib

But when I try use it in ma code I get this message:
ModuleNotFoundError: No module named 'matplotlib'

Any comments ?

Thanks.




RE: matplotlib isn't recognized after installation - buran - Sep-18-2019

How many python installations do you have? Do you use virtual environments? How do you run your code?


RE: matplotlib isn't recognized after installation - Pavel_47 - Sep-18-2019

I guess I've one Python installation.
Anyway I can check - does exist any instriuction in Linux to check this ?
I use Jupyter as environment and run my code there.


RE: matplotlib isn't recognized after installation - buran - Sep-18-2019

if you are on Linux most distros come with python2 and python3 installed. python will run system python2, so I guess you installed matplotib in system python2. Now the question is what version runs in Jupyter

you can run $ which python to see what version invoke python command.


RE: matplotlib isn't recognized after installation - Pavel_47 - Sep-18-2019

The Jupyter version: 3.6.8

Executing $which python in terminal outputs this: Python 2.7.15+

Resolved.
The instruction sudo apt-get install python3-matplotlib fixed the problem.
Thanks.


RE: matplotlib isn't recognized after installation - snippsat - Sep-18-2019

Remember to use pip3 in the future not pip(as it install to Python 2).
Look also at pyenv Simple Python Version Management can make stuff simpler.