PyCharm cannot import tensorflow.keras

I am working with the tensorflow-implementation from Keras and I can use it without issues, however, my IDE thinks that the keras submodule in tf does not exist. I am using anaconda where I install tensorflow and all my other libraries. I make sure that I select the right interpreter in PyCharm (all my other obscure libraries are imported without issue) and the base module from tf is imported without any problem (I get autocomplete etc.) but when I import "tensorflow.keras" the IDE complains that it cannot find the reference 'keras'. As said above, executing the files works without problem. Is there a way to tell the PyCharm that there is actually a keras submodule?

PyCharm 2018.3.3 (Community Edition)
Build #PC-183.5153.39, built on January 9, 2019
JRE: 1.8.0_152-release-1343-b26 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-43-generic


1 comment


As a first troubleshooting step, can you try to find where the keras module is physically located in your packages directories, and check if this directory is present in the sys.path of your interpreter?

Also, please try to open python console and do the import from there.


Please sign in to leave a comment.