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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,258评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,335评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,225评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,126评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,140评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,098评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,018评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,857评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,298评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,518评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,678评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,400评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,993评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,638评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,801评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,661评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,558评论 2 352

推荐阅读更多精彩内容

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