Skip to content

Cannot import tensorflow in python #1013

Closed

Description

@orShap

My env is like this:

python 2.7.10
I successfully installed tensorflow, using pip install
https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

then I goes into python,
then import tensorflow as tf,
I got this error:

>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\__init__.py", line 22, in <module>
    from tensorflow.python.client.client_lib import *
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\client\client_lib.py", line 35, in <module>
    from tensorflow.python.client.session import InteractiveSession
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\client\session.py", line 11, in <module>
    from tensorflow.python import pywrap_tensorflow as tf_session
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
    import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow

would be greatful, thanks!

Activity

  1. mrry commented on Feb 8, 2016

    @mrry
    Contributor

    Answered this question on StackOverflow: http://stackoverflow.com/questions/35277339/cannot-import-tensorflow-in-python/35277461#35277461

    The problem is that you are trying to install the Mac version of TensorFlow on Windows, and Windows is not supported. Follow #17 for progress in that regard.

  2. kentastudillo commented on Jul 7, 2016

    @kentastudillo

    I'm using docker on my Mac and I get the same error. I'm trying to run tensorflow serving.

    root@9b82edf4d8e7:/serving# bazel-bin/tensorflow_serving/example/inception_export --checkpoint_dir=inception-v3 --export_dir=inception-export
    Traceback (most recent call last):
      File "/serving/bazel-bin/tensorflow_serving/example/inception_export.runfiles/tensorflow_serving/example/inception_export.py", line 25, in <module>
        import tensorflow as tf
      File "/serving/bazel-bin/tensorflow_serving/example/inception_export.runfiles/external/org_tensorflow/tensorflow/__init__.py", line 23, in <module>
        from tensorflow.python import *
      File "/serving/bazel-bin/tensorflow_serving/example/inception_export.runfiles/external/org_tensorflow/tensorflow/python/__init__.py", line 48, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "/serving/bazel-bin/tensorflow_serving/example/inception_export.runfiles/external/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
        _pywrap_tensorflow = swig_import_helper()
      File "/serving/bazel-bin/tensorflow_serving/example/inception_export.runfiles/external/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
        import _pywrap_tensorflow
    ImportError: No module named _pywrap_tensorflow
    
  3. zaichang commented on Nov 17, 2016

    @zaichang

    I have the same issue as killuabone as I am also using docker on OS X, running through the steps detailed here:
    https://tensorflow.github.io/serving/serving_inception.html

  4. cag472 commented on Nov 27, 2016

    @cag472

    I just had this problem and solved it, will post my results here for future readers.

    The problem (for me) was that my numpy was v1.08, whereas tensorflow wants v1.11. Upgrading numpy on El Capitan may not be easy; I had to (a) reboot in recovery mode, (b) open terminal and type "csrutil disable", (c) boot normally and upgrade numpy (pip2 install --user --upgrade numpy), (d) reboot in recovery mode again, and (e) open terminal and type "csrutil enable".

  5. alihusn commented on Jan 8, 2017

    @alihusn

    For windows users install Visual C++ 2015 redistributable (x64 version) to be able to import tensorflow

  6. Alkhoraif commented on Jan 27, 2017

    @Alkhoraif

    I got the same issue. Please, how can I solve it

    import tensorflow as tf

    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in
    import tensorflow as tf
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/init.py", line 23, in
    from tensorflow.python import *
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/init.py", line 49, in
    from tensorflow.python import pywrap_tensorflow
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 21, in
    _pywrap_tensorflow = swig_import_helper()
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module
    import(name)
    ImportError: No module named _pywrap_tensorflow

  7. arkwave commented on Feb 6, 2017

    @arkwave

    @alihusn Sorry to resurrect an old thread, but how did installing this fix your problem? I've installed Visual C++ 2015 Redistributable and have made sure that MSVCP140.DLL is in my path, yet I'm still getting the error.

  8. alihusn commented on Feb 11, 2017

    @alihusn

    Well it worked for me :P

  9. srikant86panda commented on Feb 18, 2017

    @srikant86panda

    After installation of Visual C++ 2015 Redistributable it worked for me

  10. jhli973 commented on Mar 4, 2017

    @jhli973

    I have the same error (ImportError: No module named _pywrap_tensorflow), my solution:

    Iinstall cuDNN v5.1 for CUDA 8.0
    You need to register a NVIDIA accelerated computing developer program, then from here (https://developer.nvidia.com/rdp/cudnn-download) download and unzip it.
    Copy all three subfolders and past it under CUDA folder, in my case is
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA

    Then , you should be able to load tensorflow without any error

    NOTE, I use python 3.5

  11. mrgloom commented on Mar 24, 2017

    @mrgloom

    +1

    After installation of Visual C++ 2015 Redistributable it worked for me

  12. hsinghal-wisc commented on Mar 25, 2017

    @hsinghal-wisc

    any solution for MAC users ?

  13. bhavsarpratik commented on Mar 25, 2017

    @bhavsarpratik

    Hi, I have laid down step-by-step instructions to successfully install Tensorflow on Windows.

    https://github.com/bhavsarpratik/install_Tensorflow_GPU_windows

  14. coolajitsahu commented on Aug 7, 2018

    @coolajitsahu

    hello i have also same problem ....

  15. abdulqadir88 commented on Apr 18, 2019

    @abdulqadir88

    Also facing the issue tried to install the Microsoft Visual C++ 2015 Redistributable but when i checked the control panel it is already present there

    image

    Any Help plz ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions