在安装过程中需要安装gcc和zlib,所以先进行这两个的安装:yum install zlib-devel gcc -y
然后安装pyinstaller的过程需要wheel,所以进行安装:pip3 install wheel
最后进行pyinstaller的安装应该没问题了:pip3 install pyinstaller
使用 python3 -m PyInstaller -F hello.py
在centos7上因为gcc版本过低,导致会出现所有依赖满足也无法成功安装的情况:
../../src/pyi_archive.c:417:9: error: 'for' loop initial declarations are only allowed in C99 mode for (size_t i = chunk_size - MAGIC_SIZE + 1; i > 0; i--
这个时候需要升级gcc版本,通过scl项目可以简单方便地升级:
Developer Toolset 7 — Software Collections
现在最新是8了 2021-08-06号
下面是引自官网的安装方式:
Instructions You can get started in three easy steps: # 1. Install a package with repository for your system: # On CentOS, install package centos-release-scl available in CentOS repository: $ sudo yum install centos-release-scl # On RHEL, enable RHSCL repository for you system: $ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms # 2. Install the collection: $ sudo yum install devtoolset-7 # 3. Start using software collections: $ scl enable devtoolset-7 bash