Python installation Scikit-learn encounters a problem rollup

Source: Internet
Author: User
Tags python script statsmodels

Python Open Source Toolkit: Scikit-learn is a development kit for machine learning, home: http://scikit-learn.org/stable/index.html

This package to the classic machine learning algorithms are implemented using Python, is learning machine learning very good theory and practice of combining materials, but in the installation of Scikit-learn appear a variety of strange problems, here to do a summary.

To facilitate the subsequent installation of Python's various toolkits, you can install Python Easy_install first

Download Install Python installation tool
:http://pypi.python.org/pypi/setuptools 可以找到正确的版本进行下载。win7 32位可以下载setuptools-0.6c11.win32-py2.7.exe 。
I installed under: D:\pytho27\Scripts, can be a path configuration, so that the convenience of CMD directly call, similar to:


Verify that the installation is successful such as:



安装了easy_install 之后安装python的库就很简单了,以后需要安装python的库的话则直接在命令行使用 easy_install + python库的名字 如:easy_install numpy

Scikit-learn requires the following packages or tools:

    • Python (>= 2.6 or >= 3.3),
    • NumPy (>= 1.6.1),
    • SciPy (>= 0.9).
But I found a few errors after the installation: I cannot import datetime from a python script, ValueError: numpy.ufunc has the wrong size, try recompiling
importerror  :   cannot  import   name Check_build  
See http://stackoverflow.com/questions/17709641/valueerror-numpy-dtype-has-the-wrong-size-try-recompiling back.

Numpy developers follow in general a policy of keeping a backward compatible binary interface (ABI). However, the ABI is not forward compatible.

What's means:

A package, which uses numpy in a compiled extension, is compiled against a specific version of NumPy. Future version of NumPy'll be compatible with the compiled extension of the package (for exception see below). Distributers of those other packages don't need to recompile their package against a newer versions of NumPy and users do The need to update these the other packages, when the users update to a newer version of NumPy.

however, this does no go in the other direction. If A package was compiled against a specific numpy version, say 1.7, then there was no guarantee that the binaries of this P Ackage would work with older numpy versions, say 1.6, and very often or most of the time they would not.

the binary distribution of packages like Pandas and Statsmodels, that is compiled again St A recent version of NumPy, won't work when the a older version of NumPy is installed. Some packages, for example matplotlib, if I remember correctly, compile their extensions against the oldest numpy version That's they support. In this case, users with the same-old or any-recent version of NumPy can use those binaries.

The error message in the question is a typical result of binary incompatibilities.

The solution is to get a binary compatible version, either by updating numpy to at least the version against which pandas Or statsmodels were compiled, or to recompile pandas and statsmodels against the older version of NumPy that's already in Stalled.

Breaking the ABI backward compatibility:

Sometimes improvements or refactorings in NumPy break ABI backward compatibility. This happened (unintentionally) with NumPy 1.4.0. As a consequence, users, updated NumPy to 1.4.0, had binary incompatibilities with all other compiled packages, that W Ere compiled against a previous version of NumPy. This requires, all packages with binary extensions, the use NumPy has the to is recompiled to work with the ABI Incompati BLE version.

The main idea is that my numpy version and the Scikit-learn version do not match, then I uninstalled the NumPy, from numpy1.6 to 1.8 found 1.8 after the installation conflict disappears. It's a pain in the egg. Installation, we recommend you directly with the integrated environment such as: Winpython and other simple configuration environment, tools to help you match the various packages. installation under Windows is easy to install

Giant hard Company is really the hope of mankind. Installing Scikit under Windows requires only installing a "Shiquan bundle" (Cocoa name) to complete all dependent libraries. The process is as follows:

    1. Install Python2.7.6: If there is nothing to ask for, Python2 can do it. Note, however, that there are 64-bit and 32-bit differences.
    2. Install Shiquan Bundle:, contains all the scikit required libraries, and has a Python2, Python3 and 64-bit, 32-bit version, it is too convenient.
    3. Install Scikit:
    4. Finish the call.



Python installation Scikit-learn encounters a problem rollup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.