完美解决 Python library not found: libpython3.10m.dylib, Python3, .Python, lib...

577 阅读1分钟

mac 电脑上使用 $ pyinstaller -F -w xx.py 打包 Python 文件报错:

OSError: Python library not found: Python, libpython3.10.dylib, .Python, Python3, libpython3.10m.dylib
    This means your Python installation does not come with proper shared library files.
    This usually happens due to missing development package, or unsuitable build parameters of the Python installation.

    * On Debian/Ubuntu, you need to install Python development packages:
      * apt-get install python3-dev
      * apt-get install python-dev
    * If you are building Python by yourself, rebuild with `--enable-shared` (or, `--enable-framework` on macOS).

在打包过程中遇到了打包不成功的问题,看报错是 python 缺少动态库,重点错误提示:

If you are building Python by yourself, rebuild with '--enable-shared' (or, '--enable-framework' on macOS).

附:pyenv install 下载安装慢(失败)完美解决,可以快速重新安装编译好。

那么重新编译下安装下,重装要用的版本,重新编译后就会有这些动态库了:

$ env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.10.3

编译完成,然后再次打包,成功 !!!

$ pyinstaller -F -w xx.py
....
....
493 INFO: Moving BUNDLE data files to Resource directory
494 INFO: Signing the BUNDLE...
552 INFO: Building BUNDLE BUNDLE-00.toc completed successfully.

iShot_2022-11-20_01.34.46.png