[PYTHON] Intellisense doesn't work with tensorflow2.0 + VScode

Overview

It is said that code completion did not work with tensorflow2.0 + VScode and it was difficult to solve it. It was reported in here, and there was a solution, so I tried it and it worked.

Development environment windows10 VScode==1.40.0 tensorflow==2.0.0

Details

  1. Since there are tensorflow and tensorflow_core in the tensorflow installation directory (site-packages / in most cases), rename tensorflow appropriately and rename tensorflow_core to tensorflow ('tensorflow → tensorflow_back' etc.).
  2. Add the following to tensorflow / \ _ \ _ init \ _ \ _. Py (originally tensorflow_core /__init__.py).
from .python.keras.api._v2 import keras
from tensorflow_estimator.python.estimator.api._v2 import estimator

Only this. However, I have not confirmed it because there was a note that there was no problem even if there was no addition of the import statement of 2, but it may be possible to just rename.

Also, there was a way to keep the library itself unchanged, so I will introduce it.

  1. Create a symbolic link to tensorflow_core with the name tensorflow.
  2. Specify the path of the directory containing the link created in VScode settings as follows.
"python.autoComplete.extraPaths": [
        "/path/to/dir"
    ],

I thought it was best to avoid messing around with the library itself, so I tried this method at first, but it didn't work in my environment, so I had no choice but to rename it.

Recommended Posts

Intellisense doesn't work with tensorflow2.0 + VScode
What to do if intellisense doesn't work with Anaconda + VSCode + Tensorflow2.1
Tensorflow doesn't work!
VScode intellisense doesn't work on Raspberry Pi OS 64bit! (Python)
When matplotlib doesn't work with python2.7
Pip doesn't work with PyDev in Pleiades
Breakout with Tensorflow
pyenv doesn't work with tcl-tk installed by homebrew.
When send_keys doesn't work
Reading data with TensorFlow
Kyotei forecast with TensorFlow
When dropbox-sdk-python doesn't work
vscode doesn't recognize python
Try regression with TensorFlow
When I try to push with heroku, it doesn't work
Run the intellisense of your own python library with VScode.
Translate Getting Started With TensorFlow
[Python] Why pserve doesn't work
Try deep learning with TensorFlow
Use TensorFlow with Intellij IDEA
Approximate sin function with TensorFlow
Jetson Nano JETPACK 44.1 (2020/10/21) with Tensorflow
Stock price forecast with tensorflow
Fcitx doesn't work on Flatpak
Search engine work with python
Try TensorFlow MNIST with RNN
Debug shared libraries with VScode