Models: SyntaxNet ImportError: No module named _pywrap_tensorflow

Created on 15 May 2016  路  14Comments  路  Source: tensorflow/models

in OSX 10.11.4

echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh
Traceback (most recent call last):
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/syntaxnet/conll2tree.py", line 20, in <module>
    import tensorflow as tf
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/external/tf/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/external/tf/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/external/tf/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/external/tf/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
    import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow
Traceback (most recent call last):
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/syntaxnet/parser_eval.py", line 23, in <module>
    import tensorflow as tf
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
    import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow
Traceback (most recent call last):
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/syntaxnet/parser_eval.py", line 23, in <module>
    import tensorflow as tf
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Users/ilyo/dev/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
    import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow

Most helpful comment

I am also having same problem. I bet it has something to do with python.

All 14 comments

I am also having same problem. I bet it has something to do with python.

Same problem on Python 3.5. ArchLinux.

Are you running in python 2? Try python -V and it returns something other than 2.7.x then you should change it

Solved. I was missing: "Getting bash completion" from [1], thought this was only for jdk7.

[1] http://bazel.io/docs/install.html

Solved also, the problem in my case was not running all the tests, I stopped them in the middle..

I'm seeing this same issue. My Mac is running El Capitan (10.11.5), with bazel 0.2.2b. Does anyone know what could be causing it?

Have the same issue on El Capitan

Traceback (most recent call last):
File "./train.py", line 3, in
import tensorflow as tf
File "/Users/thomassonderman/tensorflow_gpu/lib/python2.7/site-packages/tensorflow/init.py", line 23, in
from tensorflow.python import *
File "/Users/thomassonderman/tensorflow_gpu/lib/python2.7/site-packages/tensorflow/python/init.py", line 48, in
from tensorflow.python import pywrap_tensorflow
File "/Users/thomassonderman/tensorflow_gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 21, in
_pywrap_tensorflow = swig_import_helper()
File "/Users/thomassonderman/tensorflow_gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "/System/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

Old, but I found this so will post for future Googlers.

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".

The problem is that the ./configure asks for python binary location, but the test scripts are hardcoded to /usr/bin/python

I had this same problem in Windows after running "pip install tensorflow".

It was fixed by running:

pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl

I'm running tf on windows 10. Installed tf with the above pip command which went fine. But as soon as I try to use tf library, I got the same error. Any suggestion?

@azhu2016 install Visual C++ 2015 redistributable (x64 version) to be able to import tensorflow

how to solve import error '_pywrap_tensorflow' in windows in python 3.5.2 ?

Was this page helpful?
0 / 5 - 0 ratings