scikit-learning 安装官网

Installing scikit-learn

Installing an official release

Scikit-learn requires:

Python (>= 2.6 or >= 3.3),

NumPy (>= 1.6.1),

SciPy (>= 0.9).

Windows

First you need to installnumpyandscipyfrom their own official installers.

Wheel packages (.whl files) for scikit-learn fromPyPIcan be installed with thepiputility. Open a console and type the following to install or upgrade scikit-learn to the latest stable release:

pip install -U scikit-learn

If there are no binary packages matching your Python version you might to try to install scikit-learn and its dependencies fromChristoph Gohlke Unofficial Windows installersor from aPython distributioninstead.

Third party distributions of scikit-learn

Some third-party distributions are now providing versions of scikit-learn integrated with their package-management systems.

These can make installation and upgrading much easier for users since the integration includes the ability to automatically install dependencies (numpy, scipy) that scikit-learn requires.

The following is an incomplete list of Python and OS distributions that provide their own version of scikit-learn.

Python(x,y) for Windows

ThePython(x,y)project distributes scikit-learn as an additional plugin, which can be found in theAdditional pluginspage.

Canopy and Anaconda for all supported platforms

CanopyandAnacondaboth ship a recent version of scikit-learn, in addition to a large set of scientific python library for Windows, Mac OSX and Linux.

Anaconda offers scikit-learn as part of its free distribution.

Warning

To upgrade or uninstall scikit-learn installed with Anaconda orcondayoushould not use the pip command. Instead:

To upgradescikit-learn:

conda update scikit-learn

To uninstallscikit-learn:

conda remove scikit-learn

Upgrading with pip install-Uscikit-learnor uninstalling pip uninstall scikit-learn is likely fail to properly remove files installed by thecondacommand.

pip upgrade and uninstall operations only work on packages installed viapipinstall.

Building on windows

To build scikit-learn on Windows you need a working C/C++ compiler in addition to numpy, scipy and setuptools.

Picking the right compiler depends on the version of Python (2 or 3) and the architecture of the Python interpreter, 32-bit or 64-bit. You can check the Python version by running the following incmdorpowershellconsole:

python–version

and the architecture with:

python -c “import struct; print(struct.calcsize(‘P’) * 8)”

The above commands assume that you have the Python installation folder in your PATH environment variable.

32-bit Python

For 32-bit Python it is possible use the standalone installers forMicrosoft Visual C++ Express 2008for Python 2 orMicrosoft Visual C++ Express 2010or Python 3.

Once installed you should be able to build scikit-learn without any particular configuration by running the following command in the scikit-learn folder:

python setup.py install

64-bit Python

For the 64-bit architecture, you either need the full Visual Studio or the free Windows SDKs that can be downloaded from the links below.

The Windows SDKs include the MSVC compilers both for 32 and 64-bit architectures. They come as a GRMSDKX_EN_DVD.iso file that can be mounted as a new drive with a setup.exe installer in it.

For Python 2 you need SDKv7.0:MS Windows SDK for Windows 7 and .NET Framework 3.5 SP1

For Python 3 you need SDKv7.1:MS Windows SDK for Windows 7 and .NET Framework 4

Both SDKs can be installed in parallel on the same host. To use the Windows SDKs, you need to setup the environment of acmdconsole launched with the following flags (at least for SDK v7.0):

cmd /E:ON /V:ON /K

Then configure the build environment with:

SET DISTUTILS_USE_SDK=1

SET MSSdk=1

“C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup\WindowsSdkVer.exe” -q -version:v7.0

“C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd” /x64 /release

Finally you can build scikit-learn in the samecmdconsole:

python setup.py install

Replace v7.0 by the v7.1 in the above commands to do the same for Python 3 instead of Python 2.

Replace/x64by/x86to build for 32-bit Python instead of 64-bit Python.

Building binary packages and installers

The.whlpackage and.exeinstallers can be built with:

pip install wheel

python setup.py bdist_wheel bdist_wininst -b doc/logos/scikit-learn-logo.bmp

The resulting packages are generated in thedist/folder.

Using an alternative compiler

It is possible to useMinGW(a port of GCC to Windows OS) as an alternative to MSVC for 32-bit Python. Not that extensions built with mingw32 can be redistributed as reusable packages as they depend on GCC runtime libraries typically not installed on end-users environment.

To force the use of a particular compiler, pass the–compilerflag to the build step:

python setup.py build –compiler=my_compiler install

wheremy_compilershould be one ofmingw32ormsvc.

《scikit-learning 安装官网》
《scikit-learning 安装官网》
《scikit-learning 安装官网》
《scikit-learning 安装官网》
《scikit-learning 安装官网》

    原文作者:hzyido
    原文地址: https://www.jianshu.com/p/a903a8599df2
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞