解决 ImportError: cannot import name pywrap_tensorflow
原文:https://aichamp.wordpress.com/2016/11/13/handeling-importerror-cannot-import-name-pywrap_tensorflow/
问题:importing tensotflow in python cli 中正常 但在jupyter中缺给出了如下错误:
ImportError: cannot import name pywrap_tensorflow
Importing tensorflow in jupyter notebook (Not working Error):
import tensorflow as tfImportErrorTraceback (most recent call last) in () 2 import cv2 as cv2 3 from PIL import Image ----> 4 import tensorflow as tf 5 #'/home/ubuntu/.local/lib/python2.7/site-packages/tensorflow' /home/ubuntu/.local/lib/python2.7/site-packages/tensorflow/__init__.py in () 21 from __future__ import print_function 22 ---> 23 from tensorflow.python import * 24 25 /home/ubuntu/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py in () 47 _default_dlopen_flags = sys.getdlopenflags() 48 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL) ---> 49 from tensorflow.python import pywrap_tensorflow 50 sys.setdlopenflags(_default_dlopen_flags) 51 ImportError: cannot import name pywrap_tensorflow
Importing tensorflow in CLI python (Working):
$ python
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.>>> import tensorflow
>>> import tensorflow as tf
>>> print(tf)
<module ‘tensorflow’ from ‘/home/ubuntu/.local/lib/python2.7/site-packages/tensorflow/__init__.pyc’>
>>> help(tf)>>> print tf.__version__
0.11.0rc2
>>> print tf.__path__
[‘/home/ubuntu/.local/lib/python2.7/site-packages/tensorflow’]
问题调查:
检查 tensorflow包的位置:
$ ls /home/ubuntu/.local/lib/python2.7/site-packages/tensorflow/
contrib core examples include init.py init.pyc models python tensorboard tools
检查 jupyter的位置
$ ps -ef | grep jupyter
ubuntu 1347 1 0 Nov11 ? 00:00:46 /usr/bin/python /usr/local/bin/jupyter-notebook –no-browser –ip=* –port=8888
其他 python 包的位置:
>> import sklearn
>>> print(sklearn.__path__)
[‘/home/ubuntu/.local/lib/python2.7/site-packages/sklearn’]
>>> import mxnet
>>> print(mxnet.__path__)
[‘/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet’]
解决方案:
- If you have installed tensorflow while jupyter is running, importing tensorflow will not work in jupyter (check if it works on python CLI). You just need to Restart jupyter notebook and it should work.
- If you have problem in both jupyter and python CLI, then you just need to start jupyter from other location.
- Ubunut 16.04 TensorFlow - ImportError: cannot import name pywrap_tensorflow
- TensorFlow - ImportError: cannot import name pywrap_tensorflow
- 解决pdfminer ImportError: cannot import name process_pdf
- 解决bs4在Python 3.6下出现“ImportError: cannot import name 'HTMLParseError'”错误
- 解决ImportError: cannot import name HTTPConnection的方法
- 安装comtypes 0.6.2时ImportError: cannot import name DistutilsOptionError 解决办法
- 解决ImportError: cannot import name xxx
- tensorflow 出现ImportError: cannot import name graph_util
- Python2下ImportError: cannot import name 'urlopen'问题解决
- 如何解决ImportError: cannot import name BeautifulSoup 或者 ImportError: No module named BeautifulSoup
- ubuntu16.04 tensorflow 报错 ImportError: cannot import name 'audio_ops'
- 解决安装pymongo报错 ImportError: cannot import name MongoClient
- python MySQLdb ImportError: cannot import name conversions 解决办法
- 解决 ImportError: cannot import name imsave 的报错问题
- 解决ImportError:cannot import name xmlrpc_client问题
- tensorflow 出现ImportError: cannot import name graph_util
- 解决ImportError: cannot import name webdriver
- 解决ImportError: cannot import name HTTPSHandler
- 解决bs4在Python 3.5下出现“ImportError: cannot import name 'HTMLParseError'”错误
- 解决ImportError: cannot import name webdriver