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

本文介绍在Mac上使用PyInstaller打包Python程序时遇到的动态库缺失问题及解决方法。通过重新配置并编译Python,最终成功解决了打包过程中的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卡尔特斯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值