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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 秋风起 寒意侵 衣衫单薄屐履轻 旧词弹 难解意 流光虚度遣谁听 不似故人音
    木木和桓桓阅读 284评论 2 10
  • 你多久没有安静的去思考了。不管是归划人生,或者是思考未来,又或者是思考一下,接下来该怎么对家人好,对家里人付出...
    陈漫燕阅读 1,070评论 0 0
  • 2016年是我过的最复杂、最混乱、最痛苦的一年,马上就是年底,愿一切不痛快能在年底画上句号,祈祷!
    景尘阅读 196评论 0 0