I'm running into problems using tensorflow 2 in VS Code. The code executes without a problem, the errors are just related to pylint in VS Code.
For example this import from tensorflow.keras.layers import Dense
gives a warning "Unable to import 'tensorflow.keras.layers'pylint(import-error)". Importing tensorflow and using tf.keras.layers.Dense
does not produce an error. I'm just using a global python environment (3.7.2) on Windows 10, tensorflow is installed via Pip.
To solve unresolved import error in Python, set your Python path in your workspace settings. If you are working with Visual Studio Code and import any library, you will face this error: “unresolved import”. Then reload the VSCode, and it will fix that error.
It seems that just tensorflow's keras module can't be imported properly, i.e. vscode's automatic completion function didn't work but other modules works fine. Sorry, something went wrong. If the problem is related to the autocomplete functions of your IDEs, then maybe this isn't a tensorflow issue.
I have read ImportError: No module named tensorflow for Visual Studio Code but it is used for working with GPU but I only want to work with CPU. How can I fix it? Thanks in advance. Show activity on this post. You should create an environment for your python project. After that, you should install tensorflow with pip.
TensorFlow Requirements TensorFlow and Keras require Python 3.6+ (Python 3.8 requires TensorFlow 2.2+), and the latest version of pip. You can determine the version of Python installed on your computer by running the following command:
Importing keras in an interpreter works but all linters and autocomplete providers cannot resolve it. Unless it's something shared by all of them I would guess it's TF
I too faced the same issue. I solved it by installing keras
as a new package and then I changed all packages name removing the prefix tensorflow.
. So in your case after installing keras
you should replace tensorflow.keras.layers
with keras.layers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With