CentOS 6 installs python2.7 and PIP

Source: Internet
Author: User
Tags install openssl openssl

Because of the release of scrapy1.0, want to test on Linux, so installed centos6.6, but its Python version of 2.6, a lot of things are not supported, so need to upgrade to 2.7;

The first is to install the virtual machine on the WINDOW7, and then install the centos6.6 system, and finally update the Python version, the specific update process is as follows (in the middle of the detour is not said, directly to the right):

1, update gcc:

Yum-y Install GCC

Tips:

Loaded Plugins:fastestmirror, Refresh-packagekit, security
Existing lock/var/run/yum.pid:another copy is running as PID 7172.
Another app is currently holding the Yum lock; Waiting for it to exit ...
Decisively delete yum.pid (root user): Rm/var/run/yum.pid

2, in order to install the setuptools, you need to install Zlib:

Yum Install zlib Zlib-dev  

2.1, to add the SSL module to Python compilation, Yum installs OpenSSL and Openssl-devel:

Yum Install Opensslyum Install Openssl-devel

2.2, in order to prevent the import zlib can not find the situation, copy the file:

Cp/usr/lib64/python2.6/lib-dynload/zlibmodule.so/usr/local/lib/python2.7/lib-dynload

3, download python2.7.10, can directly to the Python official website download, and select the corresponding version; Rename folder to Python after unpacking

4, go to Python, compile and install:

5, remove the system from the 2.6 (will remain 2.6 version:/usr/bin/python2.6)

Rm-f/usr/bin/python  

6, connect Python to a soft connection to 2.7

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

7, edit the Yum command to specify the path as 2.6, because Yum must be based on the 2.6 version

Change the #!/usr/bin/python of the file head to #!/usr/bin/python2.6
Save and exit, Yum will work. If there are other commands, the software does not work properly, follow the Yum configuration file modification method, modify its configuration file.
This completes the update.

===================================== The following is the installation portion of the PIP =================

8, install setuptools, download setuptools-18.0.1.tar.gz, unzip, enter setuptools-18.0.1, execute:

Python setup.py Install

9, install pip, download pip-7.1.0.tar.gz, unzip after entering pip-7.1.0, execute:

Python setup.py Install

10, test Pip, if error "pkg_resources." Distributionnotfound:the ' pip==7.1.2 ' distribution was not found and are required by the application ", this time you need to modify the PIP executable:

Mv/usr/bin/pip/usr/bin/pip0cp/usr/bin/pip2.7/usr/bin/pip

Attached: MySQLdb Module Installation Method:

Brief method:

Pip Install Mysql-python

Post-Installation testing:

[Email protected] ~]# Pythonpython 2.7.11 (default, OCT, 09:34:16) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on Lin Ux2type "Help", "copyright", "credits" or "license" for more information.>>> import mysqldb>>>

If normal, OK, otherwise follow these steps to install:

1, to the official website download source code: mysql-python-1.2.3.tar.gz

2, compile and install: cd mysql-python-1.2.3 && python setup.py Install

3, if an error occurs: _mysql.c:2444:error: ' _mysql_connectionobject ' has no member named ' Open ', install the following package:

Yum-y Install mysql-devel libxml2 libxml2-dev libxslt* zlib gcc OpenSSL

4, recompile the installation.

CentOS 6 installs python2.7 and PIP

Related Article

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.