1、centos7默认支持的python3版本为3.6
使用pyinstaller打包需要用到3.8的版本,需要使用scl来安装高版本的python
- scl(software collections)可以让你在同一个操作系统上安装和使用多个版本的软件,而不会影响整个系统的安装包。
- scl为社区的以下需求而设计:
- 创建和使用软件集合生产系统、概念验证系统、开发测试平台。
- scl目前已经支持fedora和rhel(衍生版本如centos也包含在内)。
2、配置scl
yum -y install centos-release-scl-rh centos-release-scl
3、安装python3.8
yum install rh-python38 --设置环境变量 cat << eof >/etc/profile.d/python38.sh # create new source /opt/rh/rh-python38/enable export x_scls="`scl enable rh-python38 'echo $x_scls'`" eof --source环境变量 source /etc/profile.d/python38.sh --设置pip数据源 mkdir ~/.pip cat << eof > ~/.pip/pip.conf [global] index-url =http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com [list] format=columns eof --安装配置pyinstaller pip3 install redis pip3.8 install wheel pip3.8 install pyinstaller --查看安装了哪些软件 [root@mysql1 ~]# pip3 list package version ------------------------- ------- altgraph 0.17.3 async-timeout 4.0.2 pip 19.3.1 pyinstaller 5.11.0 pyinstaller-hooks-contrib 2023.3 redis 4.5.5 setuptools 67.8.0 wheel 0.40.0
4、pyinstaller打包软件
pyinstaller -w -f -n redis_health_check_rhel7_v1.5 -f redis_health_check_v1.5.py
5、总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论