title: can't import keras from tensorflow
body: <p>I am trying to use keras but am unable to because when I run <code>from tensorflow import keras</code> I get this error:</p>
  
  <pre><code>➜  kerasTutorial python3
  Python 3.7.7 (default, Mar 10 2020, 15:43:33)
  [Clang 11.0.0 (clang-1100.0.33.17)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; from tensorflow import keras
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python3.7/site-packages/tensorflow/__init__.py", line 41, in &lt;module&gt;
      from tensorflow.python.tools import module_util as _module_util
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 64, in &lt;module&gt;
      from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/framework_lib.py", line 25, in &lt;module&gt;
      from tensorflow.python.framework.ops import Graph
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 64, in &lt;module&gt;
      from tensorflow.python.platform import app
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 23, in &lt;module&gt;
      from absl.app import run as _run
    File "/usr/local/lib/python3.7/site-packages/absl/app.py", line 35, in &lt;module&gt;
      import pdb
    File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pdb.py", line 76, in &lt;module&gt;
      import code
    File "/Users/mathewlewis/Documents/Y4S3/Crypto/kerasTutorial/code.py", line 4, in &lt;module&gt;
      from tensorflow.keras.models import Sequential
    File "/usr/local/lib/python3.7/site-packages/tensorflow/keras/__init__.py", line 14, in &lt;module&gt;
      from . import activations
    File "/usr/local/lib/python3.7/site-packages/tensorflow/keras/activations/__init__.py", line 10, in &lt;module&gt;
      from tensorflow.python.keras.activations import deserialize
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/__init__.py", line 27, in &lt;module&gt;
      from tensorflow.python.keras import models
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/models.py", line 23, in &lt;module&gt;
      from tensorflow.python.keras import backend as K
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/backend.py", line 36, in &lt;module&gt;
      from tensorflow.python.client import session as session_module
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 38, in &lt;module&gt;
      from tensorflow.python.framework import sparse_tensor
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/sparse_tensor.py", line 29, in &lt;module&gt;
      from tensorflow.python.framework import constant_op
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py", line 324, in &lt;module&gt;
      ops.register_tensor_conversion_function(
  AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function'
  &gt;&gt;&gt;
  </code></pre>
  
  <p>I am using python3 on mac. I have installed both keras and tensorflow using <code>pip3 install keras</code> and <code>pip3 install tensorflow</code></p>
  
  <p>I am under the impression that importing keras from tensorflow should be possible given that <a href="https://keras.io/getting_started/intro_to_keras_for_engineers" rel="nofollow noreferrer">here</a> on keras.io they provide the following sample code:</p>
  
  <pre><code>import numpy as np
  import tensorflow as tf
  from tensorflow import keras
  </code></pre>
  
  <p>Because of this, I suspect I have improperly installed either tensorflow or keras. For this reason, I have included below the results I get when I run <code>pip3 install tensorflow</code> and <code>pip3 install keras</code>:</p>
  
  <pre><code>➜  kerasTutorial pip3 install tensorflow
  Requirement already satisfied: tensorflow in /usr/local/lib/python3.7/site-packages (2.2.0)
  Requirement already satisfied: six&gt;=1.12.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.14.0)
  Requirement already satisfied: grpcio&gt;=1.8.6 in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.29.0)
  Requirement already satisfied: astunparse==1.6.3 in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.6.3)
  Requirement already satisfied: wheel&gt;=0.26; python_version &gt;= "3" in /usr/local/lib/python3.7/site-packages (from tensorflow) (0.34.2)
  Requirement already satisfied: google-pasta&gt;=0.1.8 in /usr/local/lib/python3.7/site-packages (from tensorflow) (0.2.0)
  Requirement already satisfied: h5py&lt;2.11.0,&gt;=2.10.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (2.10.0)
  Requirement already satisfied: gast==0.3.3 in /usr/local/lib/python3.7/site-packages (from tensorflow) (0.3.3)
  Requirement already satisfied: opt-einsum&gt;=2.3.2 in /usr/local/lib/python3.7/site-packages (from tensorflow) (3.2.1)
  Requirement already satisfied: protobuf&gt;=3.8.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (3.12.0)
  Requirement already satisfied: wrapt&gt;=1.11.1 in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.12.1)
  Requirement already satisfied: scipy==1.4.1; python_version &gt;= "3" in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.4.1)
  Requirement already satisfied: absl-py&gt;=0.7.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (0.9.0)
  Requirement already satisfied: tensorflow-estimator&lt;2.3.0,&gt;=2.2.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (2.2.0)
  Requirement already satisfied: tensorboard&lt;2.3.0,&gt;=2.2.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (2.2.1)
  Requirement already satisfied: keras-preprocessing&gt;=1.1.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.1.2)
  Requirement already satisfied: numpy&lt;2.0,&gt;=1.16.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.18.4)
  Requirement already satisfied: termcolor&gt;=1.1.0 in /usr/local/lib/python3.7/site-packages (from tensorflow) (1.1.0)
  Requirement already satisfied: setuptools in /Users/mathewlewis/Library/Python/3.7/lib/python/site-packages (from protobuf&gt;=3.8.0-&gt;tensorflow) (46.4.0)
  Requirement already satisfied: requests&lt;3,&gt;=2.21.0 in /usr/local/lib/python3.7/site-packages (from tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (2.23.0)
  Requirement already satisfied: markdown&gt;=2.6.8 in /usr/local/lib/python3.7/site-packages (from tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (3.2.2)
  Requirement already satisfied: google-auth&lt;2,&gt;=1.6.3 in /usr/local/lib/python3.7/site-packages (from tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (1.15.0)
  Requirement already satisfied: google-auth-oauthlib&lt;0.5,&gt;=0.4.1 in /usr/local/lib/python3.7/site-packages (from tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (0.4.1)
  Requirement already satisfied: werkzeug&gt;=0.11.15 in /usr/local/lib/python3.7/site-packages (from tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (1.0.1)
  Requirement already satisfied: tensorboard-plugin-wit&gt;=1.6.0 in /usr/local/lib/python3.7/site-packages (from tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (1.6.0.post3)
  Requirement already satisfied: chardet&lt;4,&gt;=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (3.0.4)
  Requirement already satisfied: certifi&gt;=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (2020.4.5.1)
  Requirement already satisfied: idna&lt;3,&gt;=2.5 in /usr/local/lib/python3.7/site-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (2.9)
  Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,&lt;1.26,&gt;=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (1.25.9)
  Requirement already satisfied: importlib-metadata; python_version &lt; "3.8" in /usr/local/lib/python3.7/site-packages (from markdown&gt;=2.6.8-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (1.6.0)
  Requirement already satisfied: rsa&lt;4.1,&gt;=3.1.4 in /usr/local/lib/python3.7/site-packages (from google-auth&lt;2,&gt;=1.6.3-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (4.0)
  Requirement already satisfied: cachetools&lt;5.0,&gt;=2.0.0 in /usr/local/lib/python3.7/site-packages (from google-auth&lt;2,&gt;=1.6.3-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (4.1.0)
  Requirement already satisfied: pyasn1-modules&gt;=0.2.1 in /usr/local/lib/python3.7/site-packages (from google-auth&lt;2,&gt;=1.6.3-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (0.2.8)
  Requirement already satisfied: requests-oauthlib&gt;=0.7.0 in /usr/local/lib/python3.7/site-packages (from google-auth-oauthlib&lt;0.5,&gt;=0.4.1-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (1.3.0)
  Requirement already satisfied: zipp&gt;=0.5 in /usr/local/lib/python3.7/site-packages (from importlib-metadata; python_version &lt; "3.8"-&gt;markdown&gt;=2.6.8-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (3.1.0)
  Requirement already satisfied: pyasn1&gt;=0.1.3 in /usr/local/lib/python3.7/site-packages (from rsa&lt;4.1,&gt;=3.1.4-&gt;google-auth&lt;2,&gt;=1.6.3-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (0.4.8)
  Requirement already satisfied: oauthlib&gt;=3.0.0 in /usr/local/lib/python3.7/site-packages (from requests-oauthlib&gt;=0.7.0-&gt;google-auth-oauthlib&lt;0.5,&gt;=0.4.1-&gt;tensorboard&lt;2.3.0,&gt;=2.2.0-&gt;tensorflow) (3.1.0)
  
  
  ➜  kerasTutorial pip3 install keras
  Requirement already satisfied: keras in /usr/local/lib/python3.7/site-packages (2.3.1)
  Requirement already satisfied: keras-applications&gt;=1.0.6 in /usr/local/lib/python3.7/site-packages (from keras) (1.0.8)
  Requirement already satisfied: h5py in /usr/local/lib/python3.7/site-packages (from keras) (2.10.0)
  Requirement already satisfied: keras-preprocessing&gt;=1.0.5 in /usr/local/lib/python3.7/site-packages (from keras) (1.1.2)
  Requirement already satisfied: numpy&gt;=1.9.1 in /usr/local/lib/python3.7/site-packages (from keras) (1.18.4)
  Requirement already satisfied: six&gt;=1.9.0 in /usr/local/lib/python3.7/site-packages (from keras) (1.14.0)
  Requirement already satisfied: scipy&gt;=0.14 in /usr/local/lib/python3.7/site-packages (from keras) (1.4.1)
  Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/site-packages (from keras) (5.3.1)
  </code></pre>
  
  <p>In case this is relavent, I am on a mid 2015 macbook pro, running macos catalina version 10.15.4</p>
  
  <p>This was my best attempt at including all relavent information. If you'd like to know something else please let me know and I'll try and find that out for you. Thanks very much for taking the time to read this long question.</p>
  
  <p>I have also tried using keras directly rather than importing from tensorflow. To do so I ran <code>from keras.models import Sequential</code> and got this error:</p>
  
  <pre><code>➜  kerasTutorial python3
  Python 3.7.7 (default, Mar 10 2020, 15:43:33)
  [Clang 11.0.0 (clang-1100.0.33.17)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; from keras.models import Sequential
  Using TensorFlow backend.
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python3.7/site-packages/keras/__init__.py", line 3, in &lt;module&gt;
      from . import utils
    File "/usr/local/lib/python3.7/site-packages/keras/utils/__init__.py", line 6, in &lt;module&gt;
      from . import conv_utils
    File "/usr/local/lib/python3.7/site-packages/keras/utils/conv_utils.py", line 9, in &lt;module&gt;
      from .. import backend as K
    File "/usr/local/lib/python3.7/site-packages/keras/backend/__init__.py", line 1, in &lt;module&gt;
      from .load_backend import epsilon
    File "/usr/local/lib/python3.7/site-packages/keras/backend/load_backend.py", line 90, in &lt;module&gt;
      from .tensorflow_backend import *
    File "/usr/local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in &lt;module&gt;
      import tensorflow as tf
    File "/usr/local/lib/python3.7/site-packages/tensorflow/__init__.py", line 41, in &lt;module&gt;
      from tensorflow.python.tools import module_util as _module_util
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 64, in &lt;module&gt;
      from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/framework_lib.py", line 25, in &lt;module&gt;
      from tensorflow.python.framework.ops import Graph
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 64, in &lt;module&gt;
      from tensorflow.python.platform import app
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 23, in &lt;module&gt;
      from absl.app import run as _run
    File "/usr/local/lib/python3.7/site-packages/absl/app.py", line 35, in &lt;module&gt;
      import pdb
    File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pdb.py", line 76, in &lt;module&gt;
      import code
    File "/Users/mathewlewis/Documents/Y4S3/Crypto/kerasTutorial/code.py", line 4, in &lt;module&gt;
      from tensorflow.keras.models import Sequential
    File "/usr/local/lib/python3.7/site-packages/tensorflow/keras/__init__.py", line 14, in &lt;module&gt;
      from . import activations
    File "/usr/local/lib/python3.7/site-packages/tensorflow/keras/activations/__init__.py", line 10, in &lt;module&gt;
      from tensorflow.python.keras.activations import deserialize
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/__init__.py", line 27, in &lt;module&gt;
      from tensorflow.python.keras import models
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/models.py", line 23, in &lt;module&gt;
      from tensorflow.python.keras import backend as K
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/backend.py", line 36, in &lt;module&gt;
      from tensorflow.python.client import session as session_module
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 38, in &lt;module&gt;
      from tensorflow.python.framework import sparse_tensor
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/sparse_tensor.py", line 29, in &lt;module&gt;
      from tensorflow.python.framework import constant_op
    File "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py", line 324, in &lt;module&gt;
      ops.register_tensor_conversion_function(
  AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function'
  &gt;&gt;&gt;
  </code></pre>
  
  <p>Also, I am not using conda. I'd like to have a solution which uses python3 and packages which can be installed using pip3.</p>