I am currently practicing matplotlib. This is the first example I practice.
#!/usr/bin/python
import matplotlib.pyplot as plt
radius = [1.0, 2.0, 3.0, 4.0]
So I used python3 -m pip install matplotlib' then
import matplotlib.pyplot as plt` and it worked.
First check the version of Python
For python2:
sudo apt-get install python-matplotlib
For python3:
sudo apt-get install python3-matplotlib
If you mismatch the Matplotlib installation and the Python version you will get the no-module-error because no module for that version exits.
Comment in the normal feed are blocked. Let me write why this happens, just like when you executed your app.
If you ran scripts, python or ipython in another environment than the one you installed it, you will get these issues.
Don't confuse reinstalling it. Matplotlib is normally installed in your user environment, not in sudo. You are changing the environment.
So don't reinstall pip, just make sure you are running it as sudo if you installed it in the sudo environment.
If you using Anaconda3
Just put
conda install -c conda-forge matplotlib
I bashed my head on this for hours until I thought about checking my .bash_profile. I didn't have a path listed for python3 so I added the following code:
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
And then re-installed matplotlib with sudo pip3 install matplotlib
. All is working beautifully now.
pip
will make your life easy!
Step 1: Install pip - Check if you have pip already simply by writing pip in the python console. If you don't have pip, get a python script called get-pip.py , via here: https://pip.pypa.io/en/latest/installing.html or directly here: https://bootstrap.pypa.io/get-pip.py (You may have to use Save As ..)
Step 2: Take note of where the file got saved and cd the directory from command prompt. Run the get-pip.py script to install pip. You can write in cmd this line within quotes: "python .\get-pip.py"
Step 3: Now in cmd type: pip install matplotlib
And you should be through.