Linux offline deployment Python3.6.2 environment

Linux offline deployment Python3.6.2 environment

1. Deploy python3.6.2

In the system environment before deployment, you can see that it comes with python2 and python3.7, but the program runs to ensure that the versions are completely consistent, and python3.6.2 needs to be deployed

insert image description here

Overall process:

按照以下步骤在openEuler上部署Python 3.6.2环境:

下载Python 3.6.2源代码包:
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz

解压源代码包:
tar -zxvf Python-3.6.2.tgz

安装编译依赖:
sudo yum install gcc openssl-devel bzip2-devel libffi-devel make

配置编译选项:
# 编译python源码,将编译后的环境通过make install安装到/usr/local/python3.6位置
cd Python-3.6.2
./configure --prefix=/usr/local/python3.6

编译并安装:
make && sudo make install

配置环境变量:
vim /etc/environment
#添加Path,将/usr/local/python3.6/bin位置放在/usr/bin之前
#会优先从/usr/local/python3.6/bin寻找python3,而且不影响加载系统python
export PATH="/usr/local/python3.6/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin:/usr/games:/usr/local/games"

#配置生效
source /etc/environment

现在应该已经成功部署了Python 3.6.2环境。可以通过运行以下命令来验证:
python3.6 --version
提示应该显示为“Python 3.6.2”

make和make installBoth are commands for building and installing software.

The make command is commonly used to build software from source code. It checks the Makefile in the source code and executes a series of commands defined in it to generate executables, libraries, and other necessary files. The commands defined in the Makefile usually include compiling source code, linking object files, generating documentation, and so on. When the make command is executed, it will generate object files according to the rules and dependencies in the Makefile.

The make install command is typically used to install software. It copies the built executable, libraries, and other necessary files to the appropriate directories on the system. These directories usually include /bin, /usr/bin, /lib, /usr/lib, and so on. Installers often require superuser privileges because they require access to system-level directories and files.

Generally speaking, after executing the make command, you can test whether it is working properly by running the program. If the tests pass and you want to install the program to your system, you can run the make install command. Before executing the make install command, you need to make sure that you have proper permissions to access system-level directories and files, or use the sudo command to run as superuser while executing the command.

It should be noted that the Makefile of different software may define different installation directories and file names, so before executing the make install command, please be sure to check the documentation or README file of the software to determine where they should be installed.

2. Corresponding part display

insert image description here
insert image description here

注意:
下面此处使用tar命令将编译后的python3.6文件夹打包。
此后部署Python环境,仅需要将此文件夹移植,将bin文件路径添加至/etc/environment文件中即可。

配置环境变量:
vim /etc/environment
#添加,使得安装Python3.6优先级使用大于系统自带的python3.7:
PATH="/usr/local/python3.6/bin:$PATH"
#配置生效
source /etc/environment

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/m0_45057216/article/details/129979893