Python教程

pyinstaller 打包exe遇到If you are building Python by yourself, rebuild with `--enable-shared` (or, `--en

本文主要是介绍pyinstaller 打包exe遇到If you are building Python by yourself, rebuild with `--enable-shared` (or, `--en,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

环境:pyenv + python3.8.5 +Macos

测试代码

testExe.py
#!/usr/bin/env python
# coding=utf-8


if __name__ == "__main__":
    
    print("测试打包exe")

执行步骤

  1. pyenv local 3.8.5 #已经安装对应的版本前提下
  2. pip install pyinstaller
  3. 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系统

   

这篇关于pyinstaller 打包exe遇到If you are building Python by yourself, rebuild with `--enable-shared` (or, `--en的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!