1

enter image description here

Hi

in jupyter notebook, when i tried to import tensorflow like below, i got an error of ModuleNotFoundError: No module named 'tensorflow'. Then, I opened anaconda prompt and trying to install tensorflow in anaconda and it failed many times and here is the error message. Could you please help me what is the problem? Thanks

import tensorflow as tf

ok, so i tried to downgrade python from 3.8 to 3.6 and i still got an error at the end, could anyone help pls? Thanks

EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: C:\ProgramData\Anaconda3

roudan
  • 3,082
  • 5
  • 31
  • 72

2 Answers2

1

According to TensorFlow docs, tf is compatible with python 3.5, 3.6, 3.7 or 3.8 and also python 3 64bit release is a must, so it's maybe worth to check if you don't try to install tf accidentally on 32bit version of python. https://www.tensorflow.org/install/pip#windows

import sys
print(sys.version)

I installed tf according to Anaconda docs: create fresh env, activate it, and install tf:

conda create -n myproject tensorflow
conda activate myproject
conda install tensorflow

I can see that conda automatically selected python version 3.7.9

verify:

import tensorflow as tf
tf.version.VERSION

enter image description here

lww
  • 624
  • 1
  • 7
  • 14
  • Thanks lww. it turns out my python is 32 bit. how do i do now? do I uninstall both python and annaconda and re-install 64 bit again? Thanks – roudan Nov 15 '20 at 21:42
  • No need to reinstall because you are creating separate environments. when you create such env it is isolated installation, independent of your 32bit python. by issuing commands: (1) conda create -n python=3.7.9 (2) conda activate (3) conda install tensorflow , conda should automatically create environment with 64bit python. – lww Nov 15 '20 at 21:53
  • thanks lww, do I install python 64bit first before using the commands you listed? where to download python 64bit? I think python 3.6 is more reliable to use with tensorflow? here is the link i found. https://www.python.org/downloads/release/python-3610/ – roudan Nov 15 '20 at 22:14
  • you can of course install ver 3.6 systemwide if you feel it is better for your requirements. However, you don't need to do download from python.org manually because conda will pull python version you indicate for example conda create -n python=3.6.10 – lww Nov 15 '20 at 22:19
  • thanks lww, I followed your steps and installed tensorflow and verify it tensorflow 2.1.0. I can also import tensorflow using ipython. Everything works. Then I opened jupyter notebook from the environment, and I still got an error of ModuleNotFoundError: No module named 'tensorflow' inside jupyter notebook when using import tensorflow as tf. Do you know what is the problem? Thanks – roudan Nov 16 '20 at 01:06
  • from the anaconda prompt, activate project where you have TensorFlow installed by typing "conda activate " (the default project is base) then type jupyter-lab, or "jupyter-notebook" it will cause the browser to start and that is it. if jupyter is not installed, then "conda install jupyter-lab" or "conda install jupyter-notebook" As long as you launch jupyter from activated anaconda prompt where tensorflow was successfully installed, then it must work. – lww Nov 16 '20 at 10:45
0

your python version is not compatible with this version of tensorflow. you are using python 3.8 downgrade python to either 3.5, 3.6 or 3.7. downgrading python should solve your issue.

Tasnuva Leeya
  • 2,515
  • 1
  • 13
  • 21
  • Thanks Tasnuva. I did try to downgrade python to 3.6, here is the error:(base) C:\Users\yongn>conda install python=3.6 Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: done – roudan Nov 15 '20 at 18:13