How Can I Install Tensorflow in base (root) environment

Viewed 5975

How can I install TensorFlow in the base (root) environment? The only instructions I can find to set up Tensorflow in Anaconda have me create a new environment called tf as shown here:

conda create -n tf tensorflow,
conda activate tf

Then when I run my code, I get

 ModuleNotFoundError: No module named 'tensorflow'.

It seems that the Tensorflow module is not being found when it is in the tf environment.

1 Answers

You should activate your base environment first, and then install tensorflow

conda activate base # activate some environment (here - base)
pip install tensorflow # install tensorflow (can be done via conda too, beware of cpu/gpu versions)

This

conda create -n tf tensorflow

creates new environment via conda create -n tf and any names after that like tensorflow are packages that you want to install in new environment. These packages will be available only in this particular environment. You always install packages in a single environment that is active in the moment.

Related