Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build scikit learn on windows?

When i run the script : python setup.py install from cmd i get the following error message :

ImportError: No module named sklearn._build_utils

After installing:

  • Python 2.7.2 64 bit for windows
  • Enthought Canopy which has sciPy,NumPy and matplotlib
  • setuptools
  • scikit-learn-0.13.1.win32-py2.7
like image 494
Rakesh Adhikesavan Avatar asked Mar 24 '23 15:03

Rakesh Adhikesavan


1 Answers

If you install from a binary distribution you should not try to build from source. Just reinstall the binary packages for scikit-learn and you should be able to import sklearn from your python shell.

Beware, if you use the Python installer from Canopy you should probably better use canopy to install scikit-learn as well: https://www.enthought.com/products/canopy/package-index/ (although the current version available on canopy is a bit old: 0.11 instead of 0.13.1).

If you want to install scikit-learn for your own install of Pythonn 2.7 from the binary packages repository Christoph Gohlke you should also install all the dependencies from the same repository (the scipy-stack meta package should provide them all at once).

When ever in doubt you can check which python you a running with:

>>> import sys; print(sys.executable)

to see the folder where python is installed. You can also list the folders that python uses to lookup packages in:

>>> print(sys.path)

For scikit-learn or numpy you can do:

>>> import sklearn; print(sklearn.__version__); print(sklearn.__path__)

and:

>>> import numpy; print(numpy.__version__); print(numpy.__path__)

Edit: now if you really want to build scikit-learn from source (for instance to install the development branch from the github repository, then you should:

  • uninstall any previous version of scikit-learn installed with a binary package
  • install a C compiler (either from visual studio or mingw)
  • follow the instructions from: http://scikit-learn.org/stable/developers/advanced_installation.html#building-on-windows

Edit 2 fix a typo: replaced sys.__path__ by sys.executable.

like image 138
ogrisel Avatar answered Mar 31 '23 21:03

ogrisel