Linux python pyinstaller 打包问题
1.环境
系统版本:Linux -4.19.91-24.8.el8.ks8.11.x86_64-x86_64-with-kylin-10-Sun
python 版本 :3.11.2
pyinstaller :6.10.0
pyinstaller 安装不在说明
2.打包
[root@localhost pythonNacos]# /usr/local/python3.11/bin/pyinstaller --onefile --noconsole TestNacos.py
88 INFO: PyInstaller: 6.10.0, contrib hooks: 2024.8
88 INFO: Python: 3.11.2
90 INFO: Platform: Linux-4.19.91-24.8.el8.ks8.11.x86_64-x86_64-with-glibc2.28
90 INFO: Python environment: /usr/local/python3.11
90 INFO: wrote /data/pythonNacos/TestNacos.spec
91 INFO: Module search paths (PYTHONPATH):
['/usr/local/python3.11/lib/python311.zip',
'/usr/local/python3.11/lib/python3.11',
'/usr/local/python3.11/lib/python3.11/lib-dynload',
'/usr/local/python3.11/lib/python3.11/site-packages',
'/data/pythonNacos']
158 INFO: checking Analysis
158 INFO: Building Analysis because Analysis-00.toc is non existent
158 INFO: Running Analysis Analysis-00.toc
158 INFO: Target bytecode optimization level: 0
158 INFO: Initializing module dependency graph...
158 INFO: Caching module graph hooks...
169 INFO: Analyzing base_library.zip ...
732 INFO: Processing standard module hook 'hook-heapq.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
756 INFO: Processing standard module hook 'hook-encodings.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
2474 INFO: Processing standard module hook 'hook-pickle.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
4083 INFO: Caching module dependency graph...
4154 INFO: Looking for Python shared library...
4163 INFO: Using Python shared library: /usr/local/python3.11/lib/libpython3.11.so.1.0
4163 INFO: Analyzing /data/pythonNacos/TestNacos.py
4501 INFO: Processing pre-safe-import-module hook 'hook-typing_extensions.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks/pre_safe_import_module'
4503 INFO: SetuptoolsInfo: initializing cached setuptools info...
5398 INFO: Processing standard module hook 'hook-platform.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
5448 INFO: Processing standard module hook 'hook-multiprocessing.util.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
5526 INFO: Processing standard module hook 'hook-xml.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
5888 INFO: Processing standard module hook 'hook-sysconfig.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
6302 INFO: Processing standard module hook 'hook-difflib.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks'
6369 INFO: Processing pre-safe-import-module hook 'hook-importlib_metadata.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks/pre_safe_import_module'
6537 INFO: Processing standard module hook 'hook-jinja2.py' from '/usr/local/python3.11/lib/python3.11/site-packages/_pyinstaller_hooks_contrib/stdhooks'
7561 INFO: Processing module hooks (post-graph stage)...
7624 INFO: Performing binary vs. data reclassification (2 entries)
7630 INFO: Looking for ctypes DLLs
7752 INFO: Analyzing run-time hooks ...
7756 INFO: Including run-time hook 'pyi_rth_inspect.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks/rthooks'
7761 INFO: Including run-time hook 'pyi_rth_pkgutil.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks/rthooks'
7767 INFO: Including run-time hook 'pyi_rth_multiprocessing.py' from '/usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/hooks/rthooks'
7785 INFO: Looking for dynamic libraries
8025 INFO: Warnings written to /data/pythonNacos/build/TestNacos/warn-TestNacos.txt
8043 INFO: Graph cross-reference written to /data/pythonNacos/build/TestNacos/xref-TestNacos.html
8055 INFO: checking PYZ
8055 INFO: Building PYZ because PYZ-00.toc is non existent
8055 INFO: Building PYZ (ZlibArchive) /data/pythonNacos/build/TestNacos/PYZ-00.pyz
8545 INFO: Building PYZ (ZlibArchive) /data/pythonNacos/build/TestNacos/PYZ-00.pyz completed successfully.
8553 INFO: checking PKG
8553 INFO: Building PKG because PKG-00.toc is non existent
8553 INFO: Building PKG (CArchive) TestNacos.pkg
21010 INFO: Building PKG (CArchive) TestNacos.pkg completed successfully.
21018 INFO: Bootloader /usr/local/python3.11/lib/python3.11/site-packages/PyInstaller/bootloader/Linux-64bit-intel/run
21018 INFO: checking EXE
21018 INFO: Building EXE because EXE-00.toc is non existent
21018 INFO: Building EXE from EXE-00.toc
21019 INFO: Copying bootloader EXE to /data/pythonNacos/dist/TestNacos
21020 INFO: Appending PKG archive to custom ELF section in EXE
21294 INFO: Building EXE from EXE-00.toc completed successfully.
3.问题
/usr/local/python3.11/bin/pyinstaller --onefile --noconsole TestNacos.py
/usr/local/python3.11/bin/python3.11: error while loading shared libraries: libpython3.11.so.1.0: cannot open shared object file: No such file or directory
首先查看安装路径下面有没有 这个共享库
如果存在 cd /etc/ld.so.conf.d
创建 python3.py 增加共享库路径
完成后 执行 ldconfig
再次执行成功
如果共享库不存在需要重新编译安装python
./configure --prefix=/usr/local/python3.11/ --enable-shared
make
make install
arm 下离线安装 pyinstaller
可以查看pyinstaller 依赖关系
首先升级pip 默认是22.3升级到24.2
提前下载好安装包
python3 -m pip install --upgrade pip pip-24.2-py3-none-any.whl
pip install altgraph-0.17.4-py2.py3-none-any.whl
pip install packaging-24.1-py3-none-any.whl
pip install pyinstaller_hooks_contrib-2024.8-py3-none-any.whl
注意安装顺序先安装依赖最后在安装pyinstaller-6.10.0-py3-none-manylinux2014_aarch64.whl
pip install pyinstaller-6.10.0-py3-none-manylinux2014_aarch64.whl