PyInstaller打包python程序
$pyinstaller -F casb_data.py
13496 INFO: Python library not in binary dependencies. Doing additional searching... Traceback (most recent call last): File "/usr/local/python3/bin/pyinstaller", line 8, in <module> sys.exit(run()) File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/__main__.py", line 114, in run run_build(pyi_config, spec_file, **vars(args)) File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/__main__.py", line 65, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 725, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 672, in build exec(code, spec_namespace) File "/home/cg/app_hmf/python_tencent/casb_data.spec", line 6, in <module> a = Analysis(['casb_data.py'], File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 242, in __init__ self.__postinit__() File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/datastruct.py", line 160, in __postinit__ self.assemble() File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 476, in assemble self._check_python_library(self.binaries) File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 569, in _check_python_library python_lib = bindepend.get_python_library_path() File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/depend/bindepend.py", line 945, in get_python_library_path raise IOError(msg) OSError: Python library not found: libpython3.8m.so, libpython3.8m.so.1.0, libpython3.8mu.so.1.0, libpython3.8.so.1.0 This would mean your Python installation doesn't come with proper library files. This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages * apt-get install python3-dev * apt-get install python-dev * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin) |
查看错误:OSError: Python library not found: libpython3.8m.so, libpython3.8m.so.1.0, libpython3.8mu.so.1.0, libpython3.8.so.1.0
解决提示:
If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
解决方法:
#进入下载的python安装包,解压缩目录,重新配置和编译执行
$cd /home/cg/Python-3.8.6
$./configure --prefix=/usr/local/python3 --enable-shared
出现上面情况:重新配置
$./configure --prefix=/usr/local/python3 --enable-framework
出现上面情况:重新配置
$./configure --prefix=/usr/local/python3 --enable-optimizations
这次终于配置完成了,再次编译和执行
$make && make install
再次执行打包程序
#进入python目录
$pyinstaller -F casb_data.py
提示:/usr/local/python3/bin/python3.8: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory
原因是因为python运行时没有加载到libpython3.8.so.1.0这个库文件,将其复制到响应目录
$cp /usr/local/python3/lib/libpython3.8.so.1.0 /usr/lib64/
重新执行打包程序-->执行OK,yet.
$pyinstaller -F casb_data.py
参考:https://blog.csdn.net/qq_37742059/article/details/103026800