在安裝過程中需要安裝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