pyinstaller 打包exe遇到If you are building Python by yourself, rebuild with `--enable-shared` (or, `--enable-framework` on macOS)
环境:pyenv + python3.8.5 +Macos
测试代码
testExe.py#!/usr/bin/env python
# coding=utf-8
if __name__ == "__main__":
print("测试打包exe")
执行步骤
- pyenv local 3.8.5 #已经安装对应的版本前提下
- pip install pyinstaller
- pyinstall -D testExe.py
详细报错
* 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-frameworkon macOS)
由于使用的是pyenv多版本 所以需要重新安装对应的python版本 执行
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.7.0
重新安装python并指定
PYTHON_CONFIGURE_OPTS="--enable-framework" #仅限macos系统