0

I am using anaconda with VSCode. I import tensorflow after I downloaded it and made sure I was in the correct environment, but everytime I run the program in the terminal in both VSCode and the regular terminal I am getting this error saying no module name tensorflow. it will work in jupyter notebook perfectly without running into the error. I have tried launching VSCode from the anaconda navigator as well nothing is working. What am I doing wrong?

I am using python 3.9.7 with the recommended version from google of tensorflow 2.6

desertnaut
  • 57,590
  • 26
  • 140
  • 166
mjlynch
  • 15
  • 2

3 Answers3

0

see if your python interpreter path is correct. And u can edit if u click on this at the left bottom corner of vs code.

enter image description here

Click on this enter image description hereand vs code will show u all python interpreters it found all if your path is not there u can select it manually

  • 1
    I tried that and it's in the correct environment but it is still giving me the error. I went in and even checked to see if tensor flow was installed and it's right there next to all the packages it requires. I think I have made the decision to just start using jupyter notebook instead. A lot less headaches will be had by doing that. – mjlynch Jan 02 '22 at 19:39
  • another thing u can try is to open the folder of the virtual environment via open folder and then select the right interpreter – gerda die gandalfziege Jan 02 '22 at 20:14
0

Have you checked which python environment you are using in the terminal?

get-command python
pip --version
pip show tensorflow

And which python interpreter you have selected in the Jupyter NoteBook?

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
0

After installing VS code in your system, You need to install python extension for VS code. Then click on "Create new Jupyter notebook" and select the appropriate Python interpreter(virtual environment) as in Anaconda to run the TensorFlow code.

Please check this similar issue for your reference.