Just like the title says. My vscode does not recognize and cannot access tensorflow although I have installed it.
I had trouble making pip install tensorflow
work in the first place, but managed to solve it by creating a venv virtual environment for my interpreter and downgrading python to version 3.9.7. (Tensorflow version is 2.16.1, checked with pip show tensorflow
)
However, when I actually try to import it on code this happens.
Can’t embed photos so I’ll spell it out too.
import tensorflow
shows up half transparent, and it says ‘Cannot access “tensorflow” (Pylance)’ when hovering over it, but does correctly show the explanation for the module tensorflow below it.
In from tensorflow import keras
, keras shows up grey, and says ‘Cannot access “keras” (Pylance)’ when hovering. No explanation for the module shows up.
And import tensorflow.keras
outputs a warning saying ‘Import “tensorflow.keras” could not be resolved Pylance(reportMissingImports)’. This is the actual line of code that I’m trying to run.
I have no idea why this inconsistency happens. I’ve tried so many things that claimed to have solved the problem for others with similar problems, to no avail.
Any help or insight would be much appreciated.
aureum is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1