CentOS 7 Installation python3.6.1

Source: Internet
Author: User

CENTOS7 installed by default python2.7.5, when you need to use Python3, you can manually download the Python source code after compiling the installation.

Python official website: www.python.org


1. Install the dependencies that Python may use
Yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel


2. Download the source package
#cd/USR/LOCAL/SRC
#wget HTTPS://WWW.PYTHON.ORG/FTP/PYTHON/3.6.1/PYTHON-3.6.1.TAR.XZ
Or
#wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

These two packages are free to download any


3. Installation
Unpack the source package into the extracted Python source package directory
#tar ZXVF python-3.6.1.tgz
#cd Python-3.6.1

Compiling the installation
#./configure--prefix=/usr/local/python3
#make && make Install


4. at this point, the installation is complete

Edit/etc/profile File
Vim/etc/profile
Finally, add the following line
Path= $PATH:/usr/local/python3/bin/
Exprot PATH

Save exit


Later we want to use Python2, direct command Python2
Want to use Python3, direct command Python3
This is where python2 and python3 coexist.


5. If you want the system to perform python3 by default, do the following

#mv/usr/bin/python/usr/bin/python.bak
#ln-S/usr/local/python3/bin/python3/usr/bin/python

Because Yum makes some python2, it may not work properly after being replaced with Python3;


Modifying the Yum configuration file
Vim/usr/bin/yum
Change the first line of the head #!/usr/bin/python
#!/usr/bin/python2.7

Save to exit


CentOS 7 Installation python3.6.1

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.