models icon indicating copy to clipboard operation
models copied to clipboard

SyntaxNet ImportError: No module named _pywrap_tensorflow

Open ilyador opened this issue 10 years ago • 14 comments

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

ilyador avatar May 15 '16 11:05 ilyador

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

ainewsbot avatar May 15 '16 15:05 ainewsbot

Same problem on Python 3.5. ArchLinux.

vad23klev avatar May 16 '16 10:05 vad23klev

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

veggiedefender avatar May 16 '16 20:05 veggiedefender

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

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

ainewsbot avatar May 16 '16 23:05 ainewsbot

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

ilyador avatar May 18 '16 09:05 ilyador

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?

p-somers avatar Jun 06 '16 18:06 p-somers

Have the same issue on El Capitan

trsonderm avatar Sep 11 '16 18:09 trsonderm

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

trsonderm avatar Sep 11 '16 18:09 trsonderm

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

cag472 avatar Nov 27 '16 03:11 cag472

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

t0suj4 avatar Dec 05 '16 12:12 t0suj4

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

cbielsa avatar Dec 11 '16 21:12 cbielsa

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 avatar Dec 12 '16 16:12 azhu2016

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

alihusn avatar Jan 08 '17 20:01 alihusn

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

B-R-P avatar May 29 '17 11:05 B-R-P