Unable to import Keras(from TensorFlow 2.0) in PyCharm

前端 未结 2 1336
臣服心动
臣服心动 2020-12-17 23:05

I have just installed the stable version of TensorFlow 2.0 (released on October 1st 2019) in PyCharm.

The problem is that the keras package

2条回答
  •  醉梦人生
    2020-12-18 00:01

    SOLVED --- See the answers to this problem below.

    SOLUTION 1 (best solution)

    Is the accepted answer provided above. It works on EAP version, I tested it on several machines with Windows.

    SOLUTION 2

    Although PyCharm does not recognise the modules, running the .py file works. I still do not know if this is a problem of TensorFlow or PyCharm, but this is the solution that I have found, many people have run into this problem.

    SOLUTION 3

    Import the modules from tensorflow_core instead of tensorflow

    Example: from tensorflow_core.python.keras.preprocessing.image import ImageDataGenerator

    However, as mentioned by @Nagabhushan S N in the comment below and above in the accepted answer:

    On the other hand avoid imports from tensorflow_core if you do not want to refactor your code in the future.

提交回复
热议问题