Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to import tensorflow, matplotlib, numpy, and keras. When I try to do this I get an error saying that the module does not exist.

import tensorflow as tf 
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt 

data = keras.dataset_fashion_mnist

(train_images, train_labels), (test_images, test_labels) = data.data_load()

print(train_labels[1])
I expect the output to be a number between 1 and 10.

There might be an error such as:

C:\Users\admin\Desktop>python "tensorflow.py"
Traceback (most recent call last):
  File "tensorflow.py", line 2, in <module>
    import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
Note that this is not the only module that is having issues. Same thing happens with numpy and tensorflow.


What I have tried:

I have tried installing the latest version of everything as well as reinstalling them.
Posted
Comments
Richard MacCutchan 9-Nov-19 3:46am    
Check where these modules are installed, as python is clearly complaining that it cannot find them in the expected locations.
Khosraw 10-Nov-19 15:10pm    
@RichardMacCutchan Where do I find that out?
I used the where pip and it gave me this:
C:\Users\Khosr\AppData\Local\Programs\Python\Python37-32\Scripts\pip.exe
Richard MacCutchan 11-Nov-19 4:08am    
But that is not the missing import. Try: pip show matplotlib
Khosraw 11-Nov-19 19:15pm    
I am reinstalling Python. I will install everything again and then see if I still get the error. If I do, I will tell you what I get for that command.
Richard MacCutchan 12-Nov-19 3:07am    
Maybe it would be better to find out what the problem is first.

1 solution

So I reinstalled Python entirely from the computer but installed a 64-bit Python 3.7.5. Using the Microsoft Installing and Uninstalling Trouble Shooting Tool, I was able to uninstall it from my computer entirely. 
https://support.microsoft.com/en-us/help/17588/windows-fix-problems-that-block-programs-being-installed-or-removed
Also, use Ccleaner to clean your registry for any errors from Python.
Run the installation and install the libraries again. This will solve the problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900