import matplotlib.pyplot as plt in python3.7 - python

when i run python3.7 in pycharm(matplotlib error)
import matplotlib.pyplot as plt
then i get
Traceback (most recent call last):
File "D:/PyCharm 2017.2.3/Workplace/SimpleGA-master/ga.py", line 3, in
<module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
and i tried to find matplotlib in https://pypi.python.org/pypi/matplotlib,but not find python3.7 package

Make sure you have installed the matplotlib modules.
+ pip install matplotlib
Then try again.
Thanks!

Related

I can't use matplotlib from a script [duplicate]

This question already has answers here:
No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
(5 answers)
Why I receive ModuleNotFoundError, while it is installed and on the sys.path?
(1 answer)
Closed 1 year ago.
Can somebody help me with this problem?
Python recognises matplotlib from the command line:
import matplotlib
matplotlib.__version__
'3.4.3'
But not from a script
This is my script (to keep it simple):
import matplotlib.pylab as plt
import numpy as np
These are the errors:
Traceback (most recent call last):
File "C:/Program Files/Python39/Scripts/matplotlib.py", line 1, in <module>
import matplotlib.pylab as plt
File "C:\Program Files/Python39/Scripts\matplotlib.py", line 1, in <module>
import matplotlib.pylab as plt
ModuleNotFoundError: No module named 'matplotlib.pylab';
'matplotlib' is not a package
Try Reinstalling the package or downgrading it to a more stable version like 2.02

ModuleNotFoundError with Spyder

I downloaded spyder and practicing I have tried to use commands that generate an error.
The command is as follows:
import numpy as np
from sklearn import dataset, linear_model
import matplotlib.pyplot as plt
boston = datasets, load_boston()
print(boston)
print()
and spyder says:
runcell(0, 'C:/Users/HP/.spyder-py3/temp.py')
Traceback (most recent call last):
File "C:\Users\HP\.spyder-py3\temp.py", line 9, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
runcell(0, 'C:/Users/HP/.spyder-py3/temp.py')
Traceback (most recent call last):
File "C:\Users\HP\.spyder-py3\temp.py", line 9, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
You should install matplotlib into spyder via the pip.exe from the spyder package.
C:\Users\Ann>cd C:\ProgramData\Anaconda3\pkgs\pip-19.2.3-py37_0\Scripts
C:\ProgramData\Anaconda3\pkgs\pip-19.2.3-py37_0\Scripts>pip install matplotlib
I was having the same issue and it was resolved after I used the CMD.exe Prompt from the Anaconda navigator on Windows 10.
Note that I already had it installed fine through the windows command prompt, outside Anaconda.

Windows: ModuleNotFoundError: No module named 'matplotlib'

I'm using Python 3.7.5 and Windows 10. I installed matplotlib via pip but now if I run:
import matplotlib.pyplot as plt
The output is:
Traceback (most recent call last):
File "C:\Users\Pol\Documents\Python\hallo.py", line 1, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
How can I overcome this?

I cannot import pylab - even though matplotlib, numpy and scipy are already installed (Python)

I am sorry for asking this question again, but I could not find any answer to my problem that helped me. I don't have much experience with python. I use python version 3.6.8 on Windows and I have already installed matplotlib, numpy and scipy. The 'pylab.py' file is also contained in the matplotlib folder. Edit: Using matplotlib.pyplot also doesn't work.
Edit: After some more trials I got the error that the module 'six.names" could not be found. The six package has been installed.
import pylab
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pylab
ModuleNotFoundError: No module named 'pylab'
import matplotlib.pyplot
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
import matplotlib.pyplot
File "C:\...\Python36-32\lib\matplotlib\pyplot.py", line 30, in <module>
from cycler import cycler
File "C:\...\Python36-32\lib\cycler\cycler.py", line 48, in <module>
from six.moves import zip, reduce
ModuleNotFoundError: No module named 'six.moves'
Per https://matplotlib.org/faq/usage_faq.html#matplotlib-pyplot-and-pylab-how-are-they-related, pylab is not recommended; you should use pyplot instead.
The correct way to import either is
import matplotlib.pyplot # use this
import matplotlib.pylab # only if you cannot avoid it
(pyplot and pylab are not standalone modules, but submodules of matplotlib.)

from matplotlib.pyplot import plt ImportError: No module named 'matplotlib'

I'm on linux mint 18.3. I can import matplotlib fine, but I need to plot something from a certain file. When I try to plot something simple, I get this error:
python3 spline.py
Traceback (most recent call last):
File "spline.py", line 2, in <module>
from matplotlib.pyplot import plt
ImportError: No module named 'matplotlib'
my code in the file is:
from matplotlib.pyplot import plt
plt.plot([1, 2, 3],[2, 4, 6])
plt.show()
already tried:
pip install matplotlib
sudo apt-get install python-matplotlib
sudo apt-get install python3-matplotlib
I think in your code you should use
import matplotlib.pyplot as plt
Nevermind guys the thing was the way I was importing it, the "correct" way is:
from matplotlib import pyplot as plt
that's all now it's working

Categories

Resources