Upgrade python2.7 to python3.4.2 in CentOS

Source: Internet
Author: User
First, enter python in the command line to view your python version, the default should be more than 2.6, for example, my 2.7 install python3.4 before the recommended first install the following software package: yuminstallzlib-develbzip2-developenssl-develncurses-develsqlite-develreadline-develtk-develgccmake its

First, enter python in the command line to view your python version. the default value is 2.6 or above. for example, if my version is 2.7
We recommend that you install the following software packages before installing python3.4:
Yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

If sqlite-devel is not installed, sqlalchemy may have some problems after python3.4 is installed, such as import sqlite3.

Download the python3.4 source code package:

 

 

Wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tgz tar zxvf Python-3.4.2.tgz cd Python-3.4.2./configure -- prefix =/usr/local/python3.4 make & make install

 

 

Wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tgz

Tar zxvf Python-3.4.2.tgz

Cd Python-3.4.2

./Configure -- prefix =/usr/local/python3.4

Make & make install

 

 

 

After installation, you can see python3.4 in the/usr/local/src/python3.4/bin directory.

After the installation is complete, you need to configure python

 

 

Mv/usr/bin/python. bak ln-s/usr/local/python3.3/bin/python3.3/usr/bin/python
 

Mv/usr/bin/python. bak

Ln-s/usr/local/python3.3/bin/python3.3/usr/bin/python

Then input python in the command line to check the version. if it is 3.4.2, it will be normal.

Other problems

After python3 is installed, yum cannot be used. Solution
Follow the prompts to edit the/usr/bin/yum file and change/usr/bin/python to/usr/bin/python2.
This is mainly because yum uses the python 2 code, so you need to specify which python version to use

Add python3.4 to environment variable

Edit ~ /. Bash_profile, which will:
PATH = $ PATH: $ HOME/bin
Changed:
PATH = $ PATH: $ HOME/bin:/usr/local/python34/bin

Make the environment variable python3.4 take effect:

.~ /. Bash_profile

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.