0

I have installed Keras using pip install keras and tensorflow version 1.9.0 via python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.9.0-py2-none-any.whl. I followed the directions at this post and chose a version that seemed to be able to install on my computer. I am not sure if it is because the version is too old. I am using Python 2 on a Windows computer. I am running the following import statements and get the following error message.

from keras.models import Sequential
from keras.layers import Dense

Error:

Traceback (most recent call last):
  File "C:\Downloads\keras_code.py", line 2, in <module>
    from keras.models import Sequential
  File "C:\Python27\lib\site-packages\keras\__init__.py", line 21, in <module>
    from tensorflow.python import tf2
  File "C:\Python27\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ImportError: No module named _pywrap_tensorflow_internal


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

Getting a new computer will not be possible instantaneously, is there a way to get keras/tensorflow to work on an older computer?

Vons
  • 3,277
  • 2
  • 16
  • 19
  • 1
    on window python 2.7 not support TensorFlow https://stackoverflow.com/questions/45316569/how-to-install-tensorflow-on-python-2-7-on-windows – Waseem Randhawa Sep 06 '21 at 05:17

2 Answers2

0

@Jellyfish, you are using very old Tensorflow version. Install the latest Tensorflow version, 2.6.0. Latest Tensorflow version installs Keras library as well.

Use imports as below.

import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
0
import tensorflow as tf
from keras.models import Sequential
from keras.layers import Dense