原文: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 tf
 
ImportErrorTraceback (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’]

解决方案:

  1. 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.
  2. If you have problem in both jupyter and python CLI, then you just need to start jupyter from other location.
												

最新文章

  1. Android开发学习——基础学习
  2. distributed 以及 distributional 语义表达的区别
  3. 初步认识shell
  4. Redis 四:存储类型之列表类型
  5. php 加密解密方法
  6. poj 1830 开关问题
  7. URL传参中不能带特殊的字符以及处理方案
  8. perl 访问类方法的几种方式
  9. 清浮动,防止上下margin重叠(浏览器顶部空白崩溃)
  10. VIM文本替换命令
  11. hihocoder 1054 滑动解锁 dfs
  12. Hadoop分布式集群配置
  13. 实时语音趣味变声,大叔变声“妙音娘子”Get一下
  14. springmvc+ajax文件上传
  15. 小措施提高Linux服务器安全
  16. cnBlogs博客推荐
  17. Linux 下 SVN 命令操作详解
  18. css 层加透明度后文字依然清晰
  19. Angular 学习笔记 :初识 $digest , $watch , $apply,浅析用法 。
  20. 原型(Prototype)模式

热门文章

  1. python的super用法及含义
  2. 哈夫曼树——c++
  3. Windows下TensorFlow安装指南(图文版)
  4. php curl 伪造IP来源的实例代码
  5. vue中创建js文件使用export抛出函数,import引入后不能绑定HTML的问题
  6. 切割数组 - 将一个数组拆分成多个长度为n的数组
  7. 【12】JMicro微服务-Zookeeper
  8. 【GDKOI2017】 两个胖子萌萌哒 小学奥数题
  9. 解决ASP.NET MVC 下使用SQLite 报no such table的问题
  10. JS - 解决鼠标单击、双击事件冲突问题(原生js实现)