You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bug happened!
tensorflow.keras IDE auto-completion fails.
Using "from tensorflow." does not pop up keras, pycharm will report red but it works.
Also, tf 2.5 is normal.
I see there are other people who have had this problem
A side question - does everyone just use Notepad++? This has been a persistent issue with VSCode and Pycharm since at least 2017. I'm baffled that it's not fixed, but I don't understand it well enough to fix it myself.
I would happily just buy a different IDE if there's one that supports code completion and doesn't break on every new TF release.
A side question - does everyone just use Notepad++? This has been a persistent issue with VSCode and Pycharm since at least 2017. I'm baffled that it's not fixed, but I don't understand it well enough to fix it myself.
I would happily just buy a different IDE if there's one that supports code completion and doesn't break on every new TF release.
As far as I know, this problem appeared from 2.6 and lasted until 2.9, if it is not solved, I am willing to use pytorch in the future.
Reacted by alkatar21, builderjackm, GFHuang, ninglee, Paul Ruben, Yifan Guang, Tony Yang, gebbissimo, iuhgnor, 凌逆战 and 6 more
Not a real solution at all, but I just want to mention that Keras V3 came out yesterday. If you can already use it, then you have no problem with this anymore.
PyCharm 2023.2.5 and VSCode 1.84.2 (pylance v2023.11.10) still issue with tensorflow 2.15.0.
I'm starting learning tensorflow, keras and all of that stuff and not being able to see autocompletion and being forced to memorising optimisers, layers, metrics, params etc. is frustrating 😢
@haifeng-jin Also using import tensorflow as tf. Will switch to import keras though, since with Keras 3.0 that seems to be the recommended approach anyways.
@OlegNovosad@weidler , Thanks for the reply! Unfortunately, I don't think we can do much about the tf.keras import path.
On the Keras side, we have implemented a new mechanism for API exporting, which works for both Keras 2 (since TF 2.13) & 3 for code completion. It creates real directories and files under the import path instead of just adding attributes. So it should work with all code completion tools in IDEs.
A note for new users:
Please import keras directly in order to use the code completion feature.
Reacted by Anup Manekar, John Kwening, Eric Hine and Kevin Trebing
TensorFlow's team really really fail me for many times. Changing installation methods multiple times, annoying warnings after running code, and compatibility issues between "import" and IDE
Activity
tilakrayal commentedon May 24, 2022
@Yuri-Su ,
Could you provide the error log which you are facing issue. It helps to debug the issue. Thank you!
Dadealos commentedon May 24, 2022
So... there's no "error log" for code completion failures. As Yuri-Su mentioned, everyone is having the same issue.
Steps to reproduce:
That's literally it. If you want to rule out other IDEs, configuration issues, etc etc, just go to https://www.tensorflow.org/tutorials/quickstart/advanced
Run the first cell:

Dadealos commentedon May 24, 2022
A side question - does everyone just use Notepad++? This has been a persistent issue with VSCode and Pycharm since at least 2017. I'm baffled that it's not fixed, but I don't understand it well enough to fix it myself.
I would happily just buy a different IDE if there's one that supports code completion and doesn't break on every new TF release.
Yuri-Su commentedon May 25, 2022
As far as I know, this problem appeared from 2.6 and lasted until 2.9, if it is not solved, I am willing to use pytorch in the future.
tilakrayal commentedon May 26, 2022
@Yuri-Su ,
I was able to import and execute the code in tensorflow version 2.8. Could you find the gist of it here. Thanks you!
73 remaining items
michelkok commentedon Nov 29, 2023
Not a real solution at all, but I just want to mention that Keras V3 came out yesterday. If you can already use it, then you have no problem with this anymore.
OlegNovosad commentedon Dec 6, 2023
This is so crazy.
PyCharm 2023.2.5 and VSCode 1.84.2 (pylance v2023.11.10) still issue with tensorflow 2.15.0.
I'm starting learning tensorflow, keras and all of that stuff and not being able to see autocompletion and being forced to memorising optimisers, layers, metrics, params etc. is frustrating 😢
haifeng-jin commentedon Dec 10, 2023
@weidler @OlegNovosad Are you using
import kerasorfrom tensorflow import keras?import kerasshould always work for autocompletion.OlegNovosad commentedon Dec 10, 2023
@haifeng-jin I'm using
import tensorflow as tfand thentf.keras.<whatever>weidler commentedon Dec 11, 2023
@haifeng-jin Also using
import tensorflow as tf. Will switch toimport kerasthough, since with Keras 3.0 that seems to be the recommended approach anyways.haifeng-jin commentedon Dec 19, 2023
@OlegNovosad @weidler , Thanks for the reply! Unfortunately, I don't think we can do much about the
tf.kerasimport path.On the Keras side, we have implemented a new mechanism for API exporting, which works for both Keras 2 (since TF 2.13) & 3 for code completion. It creates real directories and files under the import path instead of just adding attributes. So it should work with all code completion tools in IDEs.
A note for new users:
Please
import kerasdirectly in order to use the code completion feature.lllllllllaa commentedon Dec 30, 2023
i made it autocompleting by changing import keras section line 397 in init.py tf 2.15 to:
can someone please tell me if it's going to crash
steveepreston commentedon Aug 28, 2024
This issue still exist in PyCharm 2024.2 with TensorFlow 2.16.1
olurocks commentedon Sep 19, 2024
Issue still persists on vscode .... 7 years down the line and no fix
interesting
steveepreston commentedon Sep 19, 2024
This issue still exist in PyCharm 2024.2.1 with TensorFlow 2.17
I'm wondering why the issue is closed! please re-open it
yuanxiqd commentedon Nov 8, 2024
This issue still exist in VScode 1.95.2 with Tensorflow 2.18.
steveepreston commentedon Nov 8, 2024
@haifeng-jin @Yuri-Su Please re-open the issue. problem still exists in TensorFlow 2.17 and 2.18
Solitaron commentedon Dec 1, 2024
TensorFlow's team really really fail me for many times. Changing installation methods multiple times, annoying warnings after running code, and compatibility issues between "import" and IDE
steveepreston commentedon Dec 7, 2024
@Letronxis Sadly worst thing is that long time issues like this are marked as closed and no one trying to open and follow them
Roobahist commentedon Apr 14, 2025
Still unresolved. VSCode 1.99.2 Tensorflow 2.18.0.