Python series-install pip and scikit-learn, pipscikit-learn

Source: Internet
Author: User

Python series-install pip and scikit-learn, pipscikit-learn

Server environment:

  • Centos7.0
  • Python2.7.5
  • Pip-6.1.1

Citation: many things are simplified due to the rush of cluster configuration. Many template libraries such as python are not installed. Today, a lab engineer is using a server to run programs and code written in python. Many library files are not imported in. The environment is configured at noon today, as a result, it took a long time to configure the python environment. Without a lunch break, my eyes were still sleepy and full of tears ~ The following describes how to install scikit-learn!

1pip Installation 1.1 download pip

Python templates can be installed in multiple ways. You do not need to download the library files manually when installing pip. Therefore, use pip here for installation.
Create a softwaredirectory under your home directory and use the wgetcommand to download pip-6.1.1.tar.gz.

mkdir softwarewget -P ~/software/ https://pypi.python.org/packages/source/p/pip/pip-6.1.1.tar.gz#md5=6b19e0a934d982a5a4b798e957cb6d45
1.2 decompress pip

Switch to the software Directory and decompress pip

cd ~/softwaretar -xzf pip-6.1.1.tar.gz
1.3 install pip

Switch to pip-6.1.1 and run the command to install pip

cd pip-6.1.1pytyon setup.py install

The result is as follows:

1.4 check whether the installation is successful

Run the pip command to test the installation. See figure:

2. Install scikit-learn

Many template libraries in python have dependencies before, and the following prerequisites are required before scikit-learn is installed:

  • Python (>=2.6 or >=3.3 ),
  • NumPy (> = 1.6.1 ),
  • SciPy (>=0.9 ).
2.1 install numpy
pip install numpy

2.2 install scipy

When installing scipypip install scipyCommand Error

Find the relevant information, and finally use yum to install it. It turns out to be usable, as shown below:

yum install scipy

The result is as follows:

2.3 install scikit-learn
pip install -U scikit-learn


Note: The scikit-learn here is executed after installation is complete. If it is uninstalled, it will be used.pip uninstall scikit-learn, Because it takes time to process, the reinstallation will not be uninstalled.

3. Test

Try to import several template libraries, as shown in:

If no error is reported, congratulations, the installation is successful.

Supplement 1: Beautifulsoup4 is used for installationpip install beautifulsoup4Which of the following is used during import?from bs4 import BeautifulSoup. The following databases are usually used: nltk, pandas, etc.

Supplement 2: python multi-version Switch
Use Code

Ln-s source file target file

If you have installed python2.6 and python2.7 at the same time, you can use

ln -s /usr/local/bin/python2.7 python

Switch python to python2.7.
If an error is reported that the python file exists, userm -f /usr/local/bin/pythonRemove the python file and then execute the preceding command.
In addition, you can refer to the previous blog Linux series-to restore Python3.3.4 to Python2.6.

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.