Following error shows when I import a package, class or method from tensorflow:
Cannot find reference 'keras' in '__init__.py' less... (Ctrl+F1)
Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
This issue did not happen when using preview versions of tensorflow. However, the program still runs normally. I find package 'keras' in 'tensorflow.keras' with this error occurs in the coding interface, but it is unable to run when I change to import 'tensorflow.python.keras'. How do I solve this problem?
I am using tensorflow 2.0.0alpha and lastest version of Pycharm
PyCharm 2018.3.5 (Professional Edition)
Build #PY-183.5912.18, built on February 26, 2019
Licensed to xxx
Subscription is active until May 14, 2019
For educational use only.
JRE: 1.8.0_152-release-1343-b28 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I am currently using the TensorFlow 2 beta version installed and used to get red squiggles for the packages I imported from keras (eg. when using from tensorflow.keras import datasets, layers, models Pycharm could not make sense of datasets, layers or models).
I found that manually importing the keras package got rid of the error highlights. Go to Project Interpreter (cmd + , on macOS), click the + button, in the search bar type in "keras", choose the version you need and click on the "Install Package" button.
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