4

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?

7
  • "Using TensorFlow backend." means keras is imported correctly. Commented Sep 4, 2018 at 22:03
  • Sorry I have edited my post, the problem is when I import keras in IDE i get import error. Commented Sep 4, 2018 at 22:05
  • can you check python interpreter in pycharm, and while selecting interpreter you can see list of packages installed. check whether keras is there or not @dm5 Commented Sep 5, 2018 at 3:55
  • I just run pip list, keras packages are installed @Asif Mohamed Commented Sep 5, 2018 at 9:28
  • try opening terminal in pycharm. and check sys.path is correct or not. you might have picked wrong interpreter. @dm5. Commented Sep 5, 2018 at 9:47

2 Answers 2

1

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 
Sign up to request clarification or add additional context in comments.

2 Comments

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
it is simple I mean use the terminal to install using pip install Keras on pycharm instead of the terminal on ubuntu
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.