我想导入sage和sklearn模块,但当我尝试导入它们时,两个sage show ImportError
:
$ sage -python temp.py
Traceback (most recent call last):
File "temp.py", line 2, in <module>
from sklearn import *
ImportError: No module named sklearn
已安装所有sklean模块:
$ ipython2
In [1]: from sklearn import *
/usr/lib/python2.7/site-packages/sklearn/pls.py:7: DeprecationWarning:
This module has been moved to cross_decomposition and will be removed in 0.16
"removed in 0.16", DeprecationWarning)
$ ipython3
In [1]: from sklearn import *
/usr/lib/python3.4/site-packages/sklearn/pls.py:7: DeprecationWarning:
This module has been moved to cross_decomposition and will be removed in 0.16
"removed in 0.16", DeprecationWarning)
答案 0 :(得分:2)
我会打赌你的 Sage 版本的Python中没有安装它的大量迷你甜甜圈。
$ sage -ipython
Python 2.7.5 (default, May 6 2014, 09:27:46)
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from sklearn import *
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-d78f0aaa3480> in <module>()
----> 1 from sklearn import *
ImportError: No module named sklearn
In [2]:
假设你已经有pip
,我会做
$ sage -sh
Starting subshell with Sage environment variables set. Don't forget
to exit when you are done. Beware:
* Do not do anything with other copies of Sage on your system.
* Do not use this for installing Sage packages using "sage -i" or for
running "make" at Sage's root directory. These should be done
outside the Sage shell.
Bypassing shell configuration files...
Note: SAGE_ROOT=...
(sage-sh) :~$
然后您可以在那里安装sklearn
。您需要执行Sage shell命令,否则它将无法选择正确的环境变量来正确安装它。但是,一旦你完成了这个,你应该很高兴。