0

I'm new to tensorflow. I installed python and tensorflow. I'm getting below error after running my sample code.

I have installed tensorflow by below command. I saw that the below command seems for mac, but I have used this command only to install tensorflow, it is successfully installed. I did not get link for windows, that is why I used below link. If anyone knows actual windows installation link for tensorflow, please share and provide solution for the below issue.

pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.5.0-py3-none-any.whl

Python 3.7.0, pip 18.0, tenserflow 1.5.0, windows 10

installation_test.py

import tensorflow as tf

sess = tf.Session()

hello = tf.constant("Hellow")
print(sess.run(hello))

a = tf.constant(20)
b = tf.constant(22)

print('a + b = {0}'.format(sess.run(a+b)))

PS F:\tensorflow> python .\installation_test.py

PS F:\tensorflow> python .\installation_test.py
Traceback (most recent call last):
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(__file__)])
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 297, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\__init__.py", line 66,
in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 20, in swig_import_helper
    import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\installation_test.py", line 1, in <module>
    import tensorflow as tf
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\__init__.py", line 72,
in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(__file__)])
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 297, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\__init__.py", line 66,
in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Users\thava\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 20, in swig_import_helper
    import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
Thavaprakash Swaminathan
  • 6,226
  • 2
  • 30
  • 31

1 Answers1

0

Firstly, For windows there isn't a direct link, you have to do it from source. Refer to this link for windows: https://www.tensorflow.org/install/source_windows

Are you sure you have installed python correctly? I prefer using virtual env. Try running a basic python command like print 'hello world' to check if it is set up.

pip3 install --upgrade pip virtualenv

After installing virtual env:

virtualenv --system-site-packages -p python3 ./venv 

after running this you should see (venv): enter command:

.\venv\Scripts\activate

after this run:

pip install --upgrade tensorflow

Verify the install:

python -c "import tensorflow as tf; print(tf.__version__)"
  • Also if you are a beginner, I suggest learning to use tensorflow.js which is a web-based API as it is very easy to install and use and it can run on any computer without any installs. So if you make something on your device, you can easily just drag your folder and run it on somebody else's pc provided they have access to the internet. – Jaskeerat Singh Sarin Sep 21 '18 at 09:08
  • Hope I could help:) – Jaskeerat Singh Sarin Sep 21 '18 at 09:08