Search code examples
pythontensorflowvisual-studio-code

Cannot import tensorflow in vscode


enter image description here I have installed tensorflow in a virtual environment and can import Tensorflow in jupyter notebook or terminal. I am now learning to use VScode, so I try to launch it in the jupyter notebook within the VScode, but Tensorflow cannot be imported.

It shows ModuleNotFoundError: No module named 'tensorflow', but I have installed it and it can be used in the terminal or jupyternotebook.

I also tried to define the path of the python interpreter, but it did not work. Could someone help me out? Tons of thanks.


Solution

  • Try:

    This works for me.

    pip --version
    
    python -m pip install --upgrade pip
    
    pip3 install tensorflow==2.0.0