linux - python ImportError: No module named ’***’
问题描述
采用virtualenv方式安装tensorflow之后,在sitepackage有tensorflow包,跑官方例子没有问题,自己跑Github上的例子时候,显示
File '/home/idc/tensorflow/multi-class-text-classification-cnn-master/data_helper.py', line 3, in <module>import numpy as npImportError: No module named ’numpy’
跑其他例子显示:
(tensorflow) idc@idc-Hi-Fi-Z77X:~/tensorflow$ sudo python CNN_sentence_tensorflow-master/sentence_classfier_with_tensorflow.pyTraceback (most recent call last): File 'CNN_sentence_tensorflow-master/sentence_classfier_with_tensorflow.py', line 13, in <module>import tensorflow as tfImportError: No module named tensorflow
但是在交互环境下import都没有问题:
(tensorflow) idc@idc-Hi-Fi-Z77X:~/tensorflow/multi-class-text-classification-cnn-master$ pythonPython 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2Type 'help', 'copyright', 'credits' or 'license' for more information.>>> import numpy as np>>> import tensorflow as tf>>>
问题解答
回答1:sudo python demo.py和python demo.py不一样,sudo一般代表系统默认的python环境
[~]$ which python/usr/local/bin/python[~]$ sudo which python/usr/bin/python回答2:
你可能进入了假的虚拟环境。
相关文章:
1. linux - python 抓取公众号文章遇到验证问题2. docker 17.03 怎么配置 registry mirror ?3. javascript - 微信公号里采用七牛上传视频部分手机不能选择文件4. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””5. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?6. MySQL 如何从 datetime 类型的字段选择 date7. angular.js - angular中的a标签不起作用8. python - 怎样在linux下开发flask web应用时查看代码出错(traceback)的地方。9. sublime-text - sublime text 3中编译python(sublimeREPL),如何仅运行单行/选定部分10. PHP怎么升级?升级会导致老的网站程序不能用吗?

网公网安备