CentOS 7 under Python environment settings-1

Source: Internet
Author: User

Installing Python 3

CentOS 7 comes with Python 2.7, so if you want to use Python 3, you'll need to reinstall Python 3

1, download the Python3.5 package

wget HTTPS://WWW.PYTHON.ORG/FTP/PYTHON/3.5.1/PYTHON-3.5.1.TAR.XZ

2. Unpack the TAR Package

TAR-ZXVF PYTHON-3.5.1.TAR.XZ

3. Move Python below the/usr/local

MV Python-3.5.1/usr/local

4. Enter the Python directory

Cd/usr/local/python-3.5.1/

5. Installing the GCC software suite

Yum Install GCC

6. Configuration

./configure

7. Compiling

Make

8, compile, install

Make install

9. Delete the old soft connection, create a new soft connection to the latest Python

Rm-rf/usr/bin/python

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

10. Because Yum uses python2, it may not continue to work properly after being replaced with Python3 python2.7.5

Modify the Yum config file (sudo vi/usr/bin/yum) to change the #!/usr/bin/python of the file header to #!/usr/bin/python2.7 save and exit.

Install python pip

Because of distributions like CentOS, sometimes the source updates are compared, so when you use Yum to search Python-pip, you will say that the package is not found. Therefore, to be able to install these packages, you need to install the extension source Epel

EPEL (Http://fedoraproject.org/wik/EPEL) is a project built by the Fedora community to deliver high-quality software packages for Rhel and derivative distributions such as CentOS, Scientific Linux, etc.

First install the Epel extension source

sudo yum-y install Epel-release

Then install Python-pip

Suo yum-y Install Python-pip

Clear the cache after the installation is complete

sudo yum clean all

Add the PYTHONPATH environment variable in the shell to increase the search path for Python (/home/vamei/mylib)

Export pythonpath= $PYTHONPATH:/home/vamei/mylib

CentOS 7 under Python environment settings-1

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.