The full error is:
Traceback (most recent call last):
File "D:\pyqt4_examples\matplotlib.py", line 4, in <module>
import matplotlib.pyplot as plt
File "D:\pyqt4_examples\matplotlib.py", line 4, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
The test code is on the file histogram.py
:
import sys
for item in sys.path: print( item )
import random
import matplotlib.pyplot as plt
x = random.sample(range(1000), 30)
xbins = [0, len(x)]
print( "x: " + str( x ) )
print( "xbins: " + str( xbins ) )
plt.bar(range(0,30), x)
plt.show()
Steps
After the first time I run the code, I got the python system path double as show bellow when I do for item in sys.path: print( item )
:
D:\pyqt4_examples
F:\Python36\python36.zip
F:\Python36\DLLs
F:\Python36\lib
F:\Python36
F:\Python36\lib\site-packages
F:\Python36\lib\site-packages\Sphinx-1.5.6-py3.6.egg
F:\Python36\lib\site-packages\win32
F:\Python36\lib\site-packages\win32\lib
F:\Python36\lib\site-packages\Pythonwin
F:\Python36\lib\site-packages\setuptools-27.2.0-py3.6.egg
D:\pyqt4_examples
F:\Python36\python36.zip
F:\Python36\DLLs
F:\Python36\lib
F:\Python36
F:\Python36\lib\site-packages
F:\Python36\lib\site-packages\Sphinx-1.5.6-py3.6.egg
F:\Python36\lib\site-packages\win32
F:\Python36\lib\site-packages\win32\lib
F:\Python36\lib\site-packages\Pythonwin
F:\Python36\lib\site-packages\setuptools-27.2.0-py3.6.egg
...
Here is the erro message, just above
On the folder F:\Python36\lib\site-packages
, is correctly there the matplotlib
and matplotlib.pyplot
:
$ ls F:\Python36\lib\site-packages\matplotlib
__init__.py _mathtext_data.py animation.py blocking_input.py ...
_contour.cp36-win32.pyd _version.py backend_tools.py compat ...
_delaunay.cp36-win32.pyd... mathtext.py pyplot.py...
_image.cp36-win32.pyd afm.py bezier.py contour.py ...
...
Details
I until yesterday my Anaconda Python 2.7.13
was working wonderfully. But I decided also to install the Python 3.6
to run a new program only for the newer version. And right after that it started not working anymore.
I had not idea why so I uninstalled the Python 3, and still not working. Then I reinstalled Python 2.7 and still not working. I installed the Pythonxy and still not working.
After 4 years without formatting my computer and never deleting my data, as I always used the upgrade
tools to migrate from Windows 8.1
to Windows 10
, I completely formatted my computer deleting all my data, and installed a fresh clean install of the Windows 10 Creator Update
. And installed Python Anaconda 2.7
but still not working. Then I installed Python 3 Anaconda
and still not working. Then I uninstalled Python 2.7 and still not working.
I have not Idea why it is not working. How can I debug python, or what can I try to find the problem? I mean, it does not make any sense because it is a fresh system install, how can it immediately broke Python
? Either there is been 4 years using python on my old installation and never had problems until yesterday. Now both old and clean fresh install are not working.
My system is now:
$ systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.15063 N/A Build 15063
$ python --version
Python 3.6.1 :: Anaconda 4.4.0 (32-bit)
Related questions I could find out:
- No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
- ImportError: No module named matplotlib with matplotlib installed
- ImportError: No module named 'matplotlib.pyplot'; matplotlib is not a package
- matplotlib - ImportError: No module named _tkinter
- ImportError: No module named matplotlib in IDLE
- ModuleNotFoundError: No module named 'matplotlib.pyplot'
- Failure to import matplotlib.pyplot in jupyter (but not ipython)
- jupyter ModuleNotFoundError: No module named matplotlib
- ImportError No module named 'matplotlib'
- ImportError: No module named matplotlib
- ImportError: No module names 'matplotlib' Python 3.3
- ImportError: No module named 'matplotlib' -- Using Anaconda tensorflow environment
- Have installed matplotlib 3 times still get error: ImportError: No module named backends.backend_wxagg
- anaconda cannot import matplotlib.pyplot
- Python matplotlib installation issue