从python3(anaconda3和eclipse)

时间:2017-05-31 02:32:09

标签: python eclipse python-2.7

使用以下cmd:

conda create -n py27 python=2.7

为了将python3改为python 2.7

然后我运行了代码

from sklearn.feature_extraction import DictVectorizer
import csv
from sklearn import tree
from sklearn import preprocessing
from sklearn.externals.six import StringIO

# Read in the csv file and put features into list of dict and list of      class label
allElectronicsData = open(r'D:\mycodes\test01\AllElectronics.csv', 'rb')
reader = csv.reader(allElectronicsData)
headers = reader.next()

错误:

Finding files... done.
Importing test modules ... Traceback (most recent call last):
File "D:\huanjing\eclipse-java-neon-R-win32-    x86_64\eclipse\plugins\org.python.pydev_5.7.0.201704111357\pysrc\_pydev_runfi    les\pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname)
File "D:\mycodes\test01\tree.py", line 1, in <module>
from sklearn.feature_extraction import DictVectorizer
ImportError: No module named sklearn.feature_extraction
ERROR: Module: tree could not be imported (file:         D:/mycodes/test01/tree.py).
done.

Ran 0 tests in 0.000s

确定

看起来我改变了python版本后,我需要再次在conda中安装所有的python包吗?

1 个答案:

答案 0 :(得分:0)

是的Python 2.7和Python 3将使用不同的包。在conda环境中运行以下命令:

$ conda install numpy
$ conda install scipy
$ conda install scikit-learn