当前位置: 代码网 > it编程>前端脚本>Python > 为什么CentOS7默认Python3.6不适合PyInstaller打包

为什么CentOS7默认Python3.6不适合PyInstaller打包

2026年11月17日 • Python •我要评论
1、centos7默认支持的python3版本为3.6使用pyinstaller打包需要用到3.8的版本,需要使用scl来安装高版本的pythonscl(software collections)可以

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、总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

赞 (0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2026  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com