0

I am very frustrated with tensorflow. I have been trying for months and I cannot still run any tensorflow deep learning.

I did install python 3.6 64 bit and tensorflow 2.1 in one environment. Here is the screenshot. After than, I started jupyter notebook and tried to run the below code, and it still said: No module named 'tensorflow', what is wrong? Thank you so much for help.

enter image description here

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-41-ea9355d0033c> in <module>()
----> 1 from tensorflow.keras.callbacks import EarlyStopping
      2 from tensorflow.keras.layers import GRU, Dense
      3 from tensorflow.keras.models import Model, Sequential

ModuleNotFoundError: No module named 'tensorflow'
roudan
  • 3,082
  • 5
  • 31
  • 72
  • 1
    did you use `conda install tensorflow` to install tensorflow? If yes, then try installing using pip and then restart your jupyter notebook. It seems like the notebook is either running on different python version or in a different environment. Check `sys.executable` to see which Python it's running in, and `sys.path` to see where it's looking for imports. Remember you will need to `import sys` – Harsh Dec 23 '20 at 20:29
  • Hi Harsh, Thanks, I just use pip install tensorflow and it still not working. I check sys. Here is the output: >>> print(sys.executable) C:\Users\yongn\.conda\envs\mloilgas\python.exe, then I check sys.path, it use python 36. >>> print(sys.path) ['', 'C:\\Users\\yongn\\.conda\\envs\\mloilgas\\python36.zip', ' – roudan Dec 26 '20 at 02:06
  • Harsh, Merry Christmas and Happy Holiday! – roudan Dec 26 '20 at 02:16
  • 1
    Merry Christmas. Did you use the `sys.executable` command in the notebook? It seems it was run from IDLE. We want to check where is notebook looking in for python. – Harsh Dec 26 '20 at 10:10
  • Thanks Harsh, ok I just check sys.executable in notebook, here is the output, it is calling python36 import sys print(sys.executable) c:\python36\python.exe – roudan Dec 26 '20 at 18:39
  • 1
    Okay. Clearly, the notebook is not pointing to the conda environment. Take a look at these links to set up the notebook in conda environment or point to one. 1. https://stackoverflow.com/questions/58068818/how-to-use-jupyter-notebooks-in-a-conda-environment 2. https://medium.com/@nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084 – Harsh Dec 26 '20 at 20:35
  • 1
    Thank you Thank you Harish. It works! I followed the method 1 to install jupyter inside the environment by using conda install jupyter. After that, it is working. I run same sys.executable, here is the output: Thank you again Mr. Harish. I really appreciate your help especially during this holiday. Wish you all the best in 2021! import sys print(sys.executable) C:\Users\yongn\.conda\envs\mloilgas\python.exe – roudan Dec 26 '20 at 22:36

0 Answers0