Debian python Upgrade +pip Installation--Basic Environment configuration

Source: Internet
Author: User

First step: Download python2.7.9 version Source:

wget http://python.org/ftp/python/2.7.9/Python-2.7.9.tgz

Unzip the file

#tar ZXVF python-2.7.9. Tar.bz2[email protected]:/opt/software# CD python-2.7.9/[email protected]:/opt/software/python-2.7.9# dirconfig.guess Doc LICENSE Objects pythonconfig.sub Grammar Mac Parser Readmeconfigure Include Makefile.pre.inchPC riscosconfigure.ac Install-sh Misc pcbuild setup.pydemo Lib Modules pyconfig.h.inchTools[email protected]:/opt/software/python-2.7.9# Mkdir/usr/local/python2.7.9

Before compiling, you need to install the Zlib package first:

Download zlib-1.2.8.tar.gz from official website http://www.zlib.net/

[Email protected]:/opt/software# tar-xvf zlib-1.2. 8 . Tar.gz[email protected]:/opt/software# CD zlib-1.2. 8 [email protected]:/opt/software#./configure && make && make install

Go to the Python-2.7.9 directory and start installing Python

[Email protected]:/opt/software/python-2.7. 9#./configure--prefix=/usr/local/python2. 7.9 [email protected]:/opt/software/python-2.7. 9# make && make install

Installation is successful!

[Email protected]:/opt/software/python-2.7. 9# python-2.6. 6

The version remains 2.6.6 and now begins to upgrade Python,

View the directory where the python command resides

[Email protected]:/opt/software/python-2.7. 9  /usr/bin/python2. 6 /usr/bin/python/etc/python2. 6 /etc/python/usr/lib/python2. 6 /usr/lib/python2. 4 /usr/lib/python2. 5 /usr/local/lib/python2. 6 /usr/include/python2. 6 /usr/share/python/usr/share/man/man1/python. 1. gz

Back up the/usr/bin/python

[Email protected]:/opt/software/python-2.7. 9# Mv/usr/bin/python/usr/bin/python2. 6.6
[Email protected]:/opt/software/python-2.7. 9 # python-bash:/usr/bin/python:no such file or directory

The python command cannot be found, just add the version python2.7.9 command to the environment variable!

Mode 1:

Modify/etc/profile Add the following two lines:

Path= $PATH:/usr/local/python2. 7.9/binexport PATH

And then

[Email protected] python-2.7. 9] # source/etc/profile[[email protected] Python-2.7.  9]# python-2.7. 9

Of course, you can also create a soft connection for 2.7.9 version of Python:/usr/bin/python

[Email protected] ~]# ln-s/usr/local/python2. 7.9/bin/python2.7/usr/bin/python

Also

Ok,python Upgrade Complete

However, when running Python get-pip.py, the error occurs because Python is not fully installed and the SSL module is missing

To modify the Modules/setup file:

 for Sockets (2  for out the other# sockets line above, and possibly edit the S SL variable: #SSL=/usr/local/ssl_ssl _ssl.c         -duse_ssl-i$ (SSL)/include-i$ (SSL)/include/  OpenSSL         -l$ (SSL)/lib-lssl-lcrypto

Re-compiling

Make && make install

and error: SSL error due to Openssl-devel not installed

Use:

apt-get  install opensslapt-get install Libdev-ssl

Compile again, get it done.

Step two, install PIP see https://pip.pypa.io/en/latest/installing.html

To install PIP, securely download get-pip.py. [2]

Then run the following (which may require administrator access):

Get-pip.py

PIP is installed by default on:/usr/local/python2.7.9/bin/

You should pay attention to the PIP version of the problem, the previous/USR/BIN/PIP may be installed using the Apt-get install PYTHON-PIP,

To upgrade/usr/bin/pip to/usr/local/python2.7.9/bin/pip2.7:

Ln-s/usr/local/python2. 7.9/bin/pip2. 7  /usr/bin/pip

Ok, the PIP installation environment is built successfully!

Step three, install Python Django run must package [optional]

1, installation MySQLdb

Download mysql-python-1.2.3.tar.gz, unzip and install the website

# python setup.py Install

2, Installation Pillow

#pip Install Pillow

3. Install Uwsgi [OPTIONAL]

#pip Install Uwsgi

To create a soft link:

# ln-s/usr/local/python2. 7.9/bin/uwsgi/usr/bin/uwsgi





Debian python Upgrade +pip Installation--Basic Environment configuration

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.