我想使用 pyinstaller 在 ubuntu 16.04 中打包。python 环境由 conda 创建,其中 python=3.6.8。
当我运行 pyinstaller 时,出现以下错误。我知道 ubuntu16.04 有 python3.5,为什么 python3.6-dev 无法安装?
27087 INFO: Looking for eggs 27087 INFO: Python library not in binary dependencies. Doing additional searching... Traceback (most recent call last): File "/home/bibao/miniconda3/envs/labelmecs_pack_server/bin/pyinstaller", line 10, in <module> sys.exit(run()) File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/__main__.py", line 111, in run run_build(pyi_config, spec_file, **vars(args)) File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/__main__.py", line 63, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 838, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 784, in build exec(text, spec_namespace) File "<string>", line 23, in <module> File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 241, in __init__ self.__postinit__() File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__ self.assemble() File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 573, in assemble self._check_python_library(self.binaries) File "/home/bibao/miniconda3/envs/labelmecs_pack_server/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 676, in _check_python_library raise IOError(msg) OSError: Python library not found: libpython3.6mu.so.1.0, libpython3.6m.so.1.0, libpython3.6.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)
答案1
尝试按照消息的最后一行:
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
显然,通过 重建你的 Python ./configure --enable-shared
,并确保$LD_LIBRARY_PATH
包含你的 python3.6/lib 路径。假设你的 python3.6.8 安装在 /home/bibao/python3.6,则使用export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/bibao/python3.6/lib
添加 PATH。
我没有使用conda。但我认为你可能会用它find
来查找python路径,或者仅仅构建一个python3.6.8用于打包使用,即使后者也不够优雅。