When I run a script and import Tensorflow from cmd or Visual Studio Code it throws me the error
but when I run it from Anaconda prompt or Spyder it works well. Why does this happen??? DO I have to add anything to PATH?
When I run a script and import Tensorflow from cmd or Visual Studio Code it throws me the error
but when I run it from Anaconda prompt or Spyder it works well. Why does this happen??? DO I have to add anything to PATH?
This is due to Python
and TensorFlow
being installed only in your anaconda environment.
TensorFlow
from command prompt rather than anaconda prompt
, you need to follow the steps below:Open command prompt
as administrator (by right click and selecting run as administrator)
C:\windows\system32\python # (This will show if python is installed in this directory or can install the latest python)
C:\windows\system32\pip install --upgrade pip
C:\windows\system32\pip install tensorflow (to install tensorflow in same path)
C:\windows\system32\python>>import tensorflow as tf >>print(tf.__version__) #to check if tensorflow installed successfully and is accessible
TensorFlow
through VS code, you need to install python extension for VS code post installing VS code in your system. After successful installation of extension, you can click on "Create new Jupyter notebook" and select the appropriate Python interpreter as in Anaconda.Now the VS code is ready to run TensorFlow
code.
Please check this link for your reference.