玩蛇网提供最新Python编程技术信息以及Python资源下载!

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 np
ImportError: No module named 'numpy'

跑其他例子显示:

(tensorflow) idc@idc-Hi-Fi-Z77X:~/tensorflow$ sudo python CNN_sentence_tensorflow-master/sentence_classfier_with_tensorflow.py
Traceback (most recent call last):
  File "CNN_sentence_tensorflow-master/sentence_classfier_with_tensorflow.py", line 13, in <module>
import tensorflow as tf
ImportError: No module named tensorflow

但是在交互环境下import都没有问题:

(tensorflow) idc@idc-Hi-Fi-Z77X:~/tensorflow/multi-class-text-classification-cnn-master$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import tensorflow as tf
>>>     

你可能进入了假的虚拟环境。

sudo python demo.py和python demo.py不一样,sudo一般代表系统默认的python环境

[~]$ which python
/usr/local/bin/python
[~]$ sudo which python
/usr/bin/python

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd13975.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2017年05月23日 - 11时16分56秒 发布自玩蛇网

您现在的位置: 玩蛇网首页 > Python问题解答 > 正文内容
我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules