Error loading Python lib with PyInstaller on MacOS

前端 未结 2 731
刺人心
刺人心 2020-12-31 22:11

I am trying to package some python into an executable on MacOS (10.14.5). I am able to create the executable, but executing the resulting dist/hello_world execu

相关标签:
2条回答
  • 2020-12-31 22:44

    The latest version of Pyinstaller only supports Python 2.7, 3.5–3.7. If you downgrade to Python 3.7 it will work!

    0 讨论(0)
  • 2020-12-31 22:54

    I had success using pyenv and installing the specific version of python with the enable framework option:

    env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.7.6

    With this version of python (set using the command pyenv local 3.7.6 in the folder where hello_world.py is located), install pyinstaller (and any other modules you need) with pip. Then build with

    pyinstaller hello_world.py --onefile --clean --windowed

    which should give you a functioning dist/hello_word. As a python fledgling, I have no idea why this works as opposed to the steps in the original question. (I thought the Mac OS installer included the Python.framework by default -- I'm sure my ignorance is exposed here as this probably differs significantly from what the PYTHON_CONFIGURE_OPTS variable is doing above).

    Also possible to do all this within a virtual environment (easily managed by pyenv-virtualenv).

    0 讨论(0)
提交回复
热议问题