I am very new to python. So, my problem might be too simple to be solved. But I cannot. Please help me! I did not have any problem to use "plt", but it suddenly shows error message and does not work, when I import it. Please see the below.
>>> import matplotlib
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 6, in <module>
from matplotlib.figure import Figure, figaspect
File "/usr/lib64/python2.6/site-packages/matplotlib/figure.py", line 18, in <module>
from axes import Axes, SubplotBase, subplot_class_factory
File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 2, in <module>
import math, sys, warnings, datetime, new
File "new.py", line 12, in <module>
import matplotlib.pyplot as plt
AttributeError: 'module' object has no attribute 'pyplot'
This package is suddenly corrupted? So, I tried to install as below.I use ubuntu.
In [1]: sudo apt-get install python-matplotlib
File "<ipython-input-1-2400ac877ebd>", line 1
sudo apt-get install python-matplotlib
^
SyntaxError: invalid syntax
If I need to reinstall, please give me very detailed instruction how to do it. Thank you very much in advance.
Try to type sudo apt-get install python-matplotlib
in a terminal. In your message you typed it in ipython console. This is a bash command, not a python one.
You need to quit ipython before. For that use Ctrl + D
I have this problem before.
What the conditions of mine is that I have install multiply versions of python and numpy in my OS. That's why the python can't find the right numpy to support the matplotlib.
The method I choose to solved this problem is the modify the $PYTHONPATH by editing the file .bashrc in my home path.
Change the order of the python install path shown, like putting the path "/usr/lib/python2.7/dist-packages" in the front of the $PYTHONPATH.
Maybe you can find something amazing. Good luck for you!!
The correct answer to resolve this issue was found at the link below: https://githubmemory.com/repo/microsoft/pylance-release/issues/1656 via a comment by jakebailey. He says, "Did you install matplotlib into the environment while VS Code was running? If you reload, does this message go away?"
VSCode doesn't refresh anything. So, after you install anything via pip or pip3, it is a good idea to:
This fixed it for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With