Install python3 environment to build under Linux

Build python3 environment under Linux

What are the ways to install software on Linux?

  • The manual installation of the rpm package rejects this method and requires manual resolution of dependencies
  • yum automated installation automatically handles dependencies very easy to use
  • Source code compilation and installation, more customizable functions, specify the software installation path
  • Download the binary source code, this software has been compiled and installed, and the executable file has been upgraded
    • Download the compressed package and directly unzip it to use.
编译安装python3步骤
1.安装好编译环境,  golang  对代码先编译在运行 ,python是直接运行, c语言也是编译后运行,需要gcc编译器

yum install 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 -y
2.获取python的源代码,下载且安装
opt文件是下载大型文件存放目录,我们应该cd 到opt目录进行python的下载
wget https://www.python.org/ftp/python3.6.3/Python3.6.3.tgz

3.下载完源代码包以后,进行解压缩
tar -zxvf Python-3.6.3.tgz

4.解压缩完毕之后,生成了python3.6.3的源代码目录,进入源代码目录准备开始编译
cd Python-3.6.3
5.此时准备编译三部曲,编译的第一部曲:指定python3的安装路径,以及对系统开发环境监测,使用如下命令
#命令解释
#configure是一个脚本文件,用于告诉gcc编译器,python3即将安装到哪里,以及对基础的开发环境检查。检查openssl,检查sqlite 等等
#编译的第一曲,结束后,主要生成makefile 用于编译的。

./configure --prefix=/opt/python363/

#编译的第二区开始进行软件编译
直接输入 make 指令即可

#编译第三曲,编译安装,生成python3的可执行程序,可就是生成 /opt/python363/
make install

#编译的第二曲和第三曲可以简写成 make && make install  #代表make成功之后,继续执行make install

6.等待出现如下结果,表示python3编译安装结束了
Successfully installed pip-9.0.1 setuptools-28.8.0

7.此时可以检查python3可执行程序目录。

8.配置PATH环境变量,永久修改PATH,添加Python3的bin目录放入开头位置
vim /etc/profile
写入如下内容
PATH="/opt/python363/bin:/usr/local/sbin:/usr/local/bin:/sur/sbin:/usr/bin:"
9.手动读取/etc/profile,加载文件中所有比那辆
source  /etc/profile

10.检查python3的目录,以及pip3的绝对路径。
[root@localhost etc]# which pip3
/opt/python363/bin/pip3
[root@localhost etc]# which python3
/opt/python363/bin/python3
[root@localhost etc]# 

Guess you like

Origin www.cnblogs.com/pyliuwei/p/12748601.html