Home  >  Article  >  Backend Development  >  How to install python under linux

How to install python under linux

藏色散人
藏色散人Original
2020-04-15 15:48:354110browse

How to install python under linux

How to install python under linux?

Installing python under linux

Steps to compile and install python3.6

(Video tutorial recommendation: python video tutorial)

1. Download the python3 source code package

wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz

2. Download the dependency package compiled by python3

  yum install -y gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

3. Unzip the source code package

tar -zxvf Python-3.6.6.tgz

How to install python under linux

4. Enter the source package folder

cd Python-3.6.6

5. Compile and install

1. Enter the source package directory

2.ls View the source package content

3. Release the compiled file Makefile

./configure --prefix=/opt/python36   # 指定安装目录为/opt/python36

How to install python under linux

4 .Compile

 make   # 相当于把源码包里面的代码编译成linux服务器可以识别的代码

5. Compile and install, this step will finally generate /opt/python36/

  make install

Note: Steps 4 and 5 can be executed together, but you need to use && in between Separate

  make && make install  # 先进行make,执行完成之后,才开始执行make install

and enter the /opt directory to view the python36 folder. The python3 we want is all here

/opt/python36/bin/python3
  /opt/python36/bin/pip3
  .....

6. Change the path variable of linux and add python3

to modify it /etc/profile system environment variable configuration file, add the following content

vim  /etc/profile

How to install python under linux

 ~/.bash_profile  # 这个是用户环境变量配置文件
  /etc/profile  # 系统环境变量配置文件
  PATH=/opt/python36/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

How to install python under linux

Note: Be sure to put the python3 directory in the first

7. In order to permanently take effect the path setting, add it to the /etc/profile global environment variable configuration file and reload the configuration file /etc/profile

source /etc/profile

How to install python under linux

8 .Enter pyhon3

How to install python under linux

The above is the detailed content of How to install python under linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn