Download the Python installation package
Cd/usr/local/src
Compile with the GCC compiler and zlib zlib-devel in advance.
1. Download the file
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
2. Decompression
TAR-ZXVF python-3.6.0.tgz
3. Go to unzip directory
CD Python-3.6.0
4. Compiling the installation package
./configure--prefix=/usr/local/python make && make install
5. Add Environment variables
#echo path= '/usr/local/python/bin/: $PATH ' >>/etc/profile
#source/etc/profile
6, check whether successful, execute the following code
Python3.6python 3.6.0 (Default, June 1, 14:01:43) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on Linuxtype "Help", "Co Pyright "," credits "or" license "for more information.>>> print (' Hello word ') Hello Word
Python Installation FAQs:
(1) configure:error:no acceptable C compiler found in $PATH
Solution: Yum install-y gcc
(2): Zipimport. Zipimporterror:can ' t decompress data
FIX: Install zlib zlib-devel
1, modify the system's default Python path, because the input Python command in the terminal is the default point of Python2.6.6
mv/usr/bin/python/usr/bin/python-2.6.6
2, establish a new soft connection, point to Python-3.6.0
Ln-s/usr/local/python/bin/python3.6/usr/bin/python
3, because Yum is dependent on python, so here we modify the default Python, it is necessary to modify the Yum, let it run to the old version:
Vi/usr/bin/yum
Modify "#!/usr/bin/python" in the first row to "#!/usr/bin/python-2.6.6" and save
4, open a new terminal, through the python command into the Python environment, you can see that has pointed to our newly installed python3.6.0:
CentOS Installation python3.6