Upgrade python, install Pip,django

Source: Internet
Author: User
Tags install django

centos6.6 The system default Python version is python2.6.6. Currently this version is very low, the mainstream is the use of python2.7 or python3.0, python2.6.6 can only support to Django1.3.7, this Django version is too low, many features are not available, upgrade now Go to python2.6.6 to python2.7.9, then install PIP and install Django's high version via PIP!



1. Download python2.7.9
http://www.python.org/ftp/python/

2. Extracting files
TARXVF python-2.7.9.tar.bz2

3. Create the installation directory
Mkdir/usr/local/python27

4. Install Python
./configure--prefix=/usr/local/python27
Make
Make install

5. Modify the old version of ln direction (note: This change may affect the use of Yum)
[[Email protected]pip-1.5.6]# mv/usr/bin/python/usr/bin/python2.6.6

[Email protected] pip-1.5.6]# ln-s/usr/local/python27/bin/python/usr/bin/python



Error:

[email protected] pip-1.5.6]# Yum Clean all

There was a problem importing one of the Python modules

Required to run Yum. The error leading to this problem was:


No module named Yum


Install a package which provides this module, or

Verify the module is installed correctly.


It ' s possible that the above module doesn ' t match the

Current version of Python, which is:

2.7.9 (Default, Dec 17 2014, 16:50:28)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]


If You cannot solve this problem yourself and go to

The Yum FAQ at:

Http://yum.baseurl.org/wiki/Faq



Error Reason: The error message is described as incompatible with the python that Yum relies on, please install the corresponding Python



[Email protected] pip-1.5.6]# Rpm-qa | grep Yum

Yum-metadata-parser-1.1.2-16.el6.x86_64

Yum-plugin-fastestmirror-1.1.30-30.el6.noarch

Packagekit-yum-0.5.8-23.el6.x86_64

Yum-3.2.29-60.el6.centos.noarch

Yum-plugin-security-1.1.30-30.el6.noarch

Packagekit-yum-plugin-0.5.8-23.el6.x86_64

Yum-utils-1.1.30-30.el6.noarch

You have new mail in/var/spool/mail/root



[[email protected] pip-1.5.6]# Whereis python

Python:/usr/bin/python2.6/usr/bin/python/usr/lib/python2.6/usr/lib64/python2.6/usr/include/python2.6/usr/share /man/man1/python.1.gz

[Email protected] pip-1.5.6]# python-v

Python 2.7.9



Now there are two versions of python!!! on the system. Yum is written by Python!

One is I just installed 2.7.9, one is the CentOS default installation of the 2.6.6

But I carried out the following:

[Email protected] pip-1.5.6]# mv/usr/bin/python/usr/bin/python2.6.6

[Email protected] pip-1.5.6]# ln-s/usr/local/python27/bin/python/usr/bin/python

[Email protected] downloads]# python-v

Python 2.7.9



[email protected] pip-1.5.6]# which Yum

/usr/bin/yum This file uses Python, it seems that this Yum does not support, 2.7.9 high version of Python

Solve:

[Email protected] pip-1.5.6]# Vim/usr/bin/yum

Change the python environment to python2.6.6



Pip:python Package Management Tools

Install PIP below:

Before installing: Install Opensslopenssl-devel First, you will know after

Https://pip.pypa.io/en/latest/installing.html



PIP uses the document:

Https://pypi.python.org/pypi/pip#downloads



I install and download:

[Email protected] pip-1.5.6]# pwd

/tmp/pip-1.5.6

[[email protected] pip-1.5.6]# ls

AUTHORS.txt Docs Pip.egg-info setup.cfg

Build LICENSE.txt Pkg-info setup.py

CHANGES.txt manifest.in PROJECT.txt setuptools-8.0.4

Dist PIP Readme.rst setuptools-8.0.4.zip



Error: Importerror:cannot Import name Httpshandler

[[Email protected] pip-1.5.6]# pip

Traceback (most recent):

File "/usr/bin/pip", line 9, <module>

Load_entry_point (' pip==1.5.6 ', ' console_scripts ', ' Pip ') ()

File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 458, in Load_entry_point

File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2545, in Load_entry_point

File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2244, in load

File "/usr/local/python27/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line ten, in <module >

From Pip.util import get_installed_distributions, Get_prog

File "/usr/local/python27/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line +, in <module>

From Pip._vendor.distlib import version

File "/usr/local/python27/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/version.py", line In <module>

From. Compat Import String_types

File "/usr/local/python27/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/compat.py", line 31 , in <module>

From URLLIB2 import (Request, Urlopen, Urlerror, Httperror,

Importerror:cannot Import Name Httpshandler



Solve:

Yuminstall-y OpenSSL Openssl-devel

Then recompile python!!



Install Django: Version: 1.7.1

[[email protected] downloads]# Pipinstall Django

Downloading/unpacking Django

DOWNLOADINGDJANGO-1.7.1-PY2.PY3-NONE-ANY.WHL (7.4MB): 20% 1.5MB


However, the tragedy is:

After the Python upgrade, the KVM graphics management interface will not open, but the KVM virtual machine is not hanging off, just said, the graphical management interface hangs!!!



Error:

[[Email protected] ~] #virt-manager

Traceback (most recent Calllast):

File "/usr/share/virt-manager/virt-manager.py", line, in<module>

Main ()

File "/usr/share/virt-manager/virt-manager.py", line 251, Inmain

From Virtmanager IMPORTCLI

File "/usr/share/virt-manager/virtmanager/cli.py", line, in<module>

Import Libvirt

Importerror:no module named Libvirt

You have new mail in/var/spool/mail/root



Solve:

[Email protected] ~]#/usr/bin/python2.6.6-v

Python 2.6.6

[Email protected] ~]#/usr/bin/python2.7-v

Python 2.7.9



Start Virt-manager with python2.6.6:

[[Email protected] ~]#/usr/bin/python2.6.6 "/usr/share/virt-manager/virt-manager.py"


This article from the "8176010" blog, reproduced please contact the author!

Upgrade python, install Pip,django

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.