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