How to install python under linux

藏色散人
Release: 2020-04-15 15:48:35
Original
4200 people have browsed it

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
Copy after login

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
Copy after login

3. Unzip the source code package

tar -zxvf Python-3.6.6.tgz
Copy after login

How to install python under linux

4. Enter the source package folder

cd Python-3.6.6
Copy after login

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
Copy after login

How to install python under linux

4 .Compile

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

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

  make install
Copy after login

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

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

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
  .....
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template