dm5
dm5

Reputation: 350

ModuleNotFoundError: No module named 'keras'

I can't import Keras in PyCharm IDE on a Mac. I have tried installing and uninstalling Keras using both pip, pip3, conda, and easy install, but none worked. I have tried changing interpreters (Python 2.7 and 3.6) but neither worked.

In a terminal, when I run:

pip3 list | grep -i keras

I get:

Keras 2.2.2
Keras-Applications 1.0.4
Keras-Preprocessing 1.0.2

I think this means that my Keras installation was successful. I have also checked my environment with:

python3 -c 'import sys, pprint; pprint.pprint(sys.path)'

I get:

'/anaconda3/lib/python36.zip', '/anaconda3/lib/python3.6', '/anaconda3/lib/python3.6/lib-dynload', '/anaconda3/lib/python3.6/site-packages', '/anaconda3/lib/python3.6/site-packages/aeosa']

I have tried running:

python -c "import keras"

I get:

Using TensorFlow backend.

But when I run/import Keras on the PyCharm IDE, I get:

ModuleNotFoundError: No module named 'keras'

What should I do to run Keras on a Mac with PyCharm 3.6?

Upvotes: 4

Views: 18395

Answers (2)

Nandu Raj
Nandu Raj

Reputation: 2110

When you start a project in PyCharm, there is an option to use an existing virtual environment or create a new virtual environment. If nothing mentioned while creating the project, new virtual environment will be created. If that is the case, there is no Keras in the new environment which is possibly your issue. It will be better to do this installation in some virtual environments and use it accordingly in Pycharm.

Upvotes: 1

Hassan_mohammad
Hassan_mohammad

Reputation: 83

I think this has a relation with the environment the pycharm using try to install Keras using pycharm terminal

in pycharm terminal apply the following

pip install Keras

Upvotes: 1

Related Questions