w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Import skitlean module in python with sage

I'll bet a pretty large stack of mini-donuts that you don't have it installed in your Sage version of Python, though.

$ 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]: 

Assuming you already have pip, I would do

$ 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) :~$

and then you can install sklearn there. You need to do the Sage shell command because otherwise it won't pick up the right environment variables to install it properly. Once you've done this, though, you should be good to go.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.