-
Notifications
You must be signed in to change notification settings - Fork 74.7k
tensorflow.keras IDE auto-completion fails #56231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@Yuri-Su , |
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 |
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 try this: |
|
@Yuri-Su try this: before:
after:
|
|
@Yuri-Su so you can't import it like that. The temporary solution can only be: before: or: |
This has been a problem for a while now, see #53144. It would be really nice if this would be fixed. It can't be that everyone who uses an IDE and code completion, which should be normal by now, has to hack around in his installation. |
Sorry for the very long wait. This issue should be addressed by #54104, which is landed on tf-nightly (but didn't included in tf 2.9). I was able to verify this locally with the latest tf-nightly pip package. Could any of you test with latest tf-nightly on the IDE and see if it fix the issue? Thanks. |
I am closing this issue. |
Just copy the folder keras from site-packages/tensorflow/python to site-packages/tensorflow. And the auto completion will start working perfectly |
It still shows tensorflow.keras could not be resolved in VScode. |
Be careful with that. It fixed the issue for me. But then I found out that it harmed performance really strong and increased model learning time 12 times.... |
Use a recent version of tensorflow. |
@haifeng-jin a change in keras will not solve anything. The problem is in tensorflow and the problem is still there in the latest pypi release _keras_module = "keras.api._v2.keras"
_keras = _LazyLoader("keras", globals(), _keras_module)
_module_dir = _module_util.get_parent_dir_for_name(_keras_module)
if _module_dir:
_current_module.__path__ = [_module_dir] + _current_module.__path__
setattr(_current_module, "keras", _keras) and most IDEs thus can't find The problem will persist until either
I don't find it realistic to require all dev tools and IDEs to adapt to that design choice. Imho it would be very beneficial for tensorflow in the future if the tensorflow dev team heeded the requests of hitherto loyal tensorflow users and responded to this somewhat annoying issue. |
This worked for me! thanks |
This issue has resurfaced in PyCharm with TF/Keras 2.15. |
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. |
This is so crazy. PyCharm 2023.2.5 and VSCode 1.84.2 (pylance v2023.11.10) still issue with tensorflow 2.15.0. |
@weidler @OlegNovosad Are you using |
@haifeng-jin I'm using |
@haifeng-jin Also using |
@OlegNovosad @weidler , Thanks for the reply! Unfortunately, I don't think we can do much about the 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: |
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 |
This issue still exist in PyCharm 2024.2 with TensorFlow 2.16.1 |
Issue still persists on vscode .... 7 years down the line and no fix interesting |
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 |
This issue still exist in VScode 1.95.2 with Tensorflow 2.18. |
@haifeng-jin @Yuri-Su Please re-open the issue. problem still exists in TensorFlow 2.17 and 2.18 |
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 |
@Letronxis Sadly worst thing is that long time issues like this are marked as closed and no one trying to open and follow them |
Still unresolved. VSCode 1.99.2 Tensorflow 2.18.0. |
Uh oh!
There was an error while loading. Please reload this page.
Click to expand!
Issue Type
Bug
Source
binary
Tensorflow Version
tf 2.8 2.9
Custom Code
Yes
OS Platform and Distribution
win mac
Mobile device
No response
Python version
3.10
Bazel version
No response
GCC/Compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current Behaviour?
Standalone code to reproduce the issue
Relevant log output
No response
The text was updated successfully, but these errors were encountered: