1

Problem:

I install keras and tensorflow correctly. Although both of them installed but i encounter with the following error when import keras:

  File "/root/PycharmProjects/DeepLearning/paper/test.py", line 1, in <module>
    import keras.activations
  File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/utils/__init__.py", line 6, in <module>
    from . import conv_utils
  File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/utils/conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/backend/__init__.py", line 89, in <module>
    from .tensorflow_backend import *
  File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py", line 6, in <module>
    from tensorflow.python.framework import ops as tf_ops
ImportError: No module named 'tensorflow.python'; 'tensorflow' is not a package

My efforts:

I try these solutions 1, 2, 3 but no result found. Also uninstall keras and tensorflow and install again but useless.

Where is the problem?

System: Ubuntu 18.04.1 LTS

Python: 3.5

Keras: 2.2.2

Tensorflow: 1.10.0

3
  • How did you install keras and tensorflow? Pip install or pip3 install? Commented Dec 18, 2019 at 16:58
  • @PallaviJog Thanks for your answer: pip install Commented Dec 18, 2019 at 17:29
  • Try pip3 install.. it will install library for python 3x Commented Dec 19, 2019 at 2:20

2 Answers 2

1

Pip3 install command instead of pip install should solve the problem.

Sign up to request clarification or add additional context in comments.

Comments

0

Since you are using Python3+, I would use pip3 install tensorflow==2.0.0

from tensorflow.keras import <whatever-module-you-need>

Tensorflow is the Keras API. You could import from either!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.