Pyinstaller:OSError:未找到Python库

3

我安装了Python 3.9.6,但也通过pyenv安装了相同版本,并将其设置为我的全局默认版本,因此在运行此命令时应显示如下结果:pyinstaller --onefile main.py

。它与我的pyenv设置的全局默认版本相同。

OSError: Python library not found: Python3, Python, libpython3.9.dylib, libpython3.9m.dylib, .Python
    This would mean your Python installation doesn't come with proper library files.
    This usually happens by missing development package, or unsuitable build parameters of Python installation.

    * On Debian/Ubuntu, you would need to install Python development packages
      * apt-get install python3-dev
      * apt-get install python-dev
    * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

我选择并设置为默认的 Python 解释器是 ~/.pyenv/versions/3.9.6/bin/python

1个回答

8

如果您使用 pyenv 安装 Python 版本,则可以参考他们的 FAQ 了解此错误信息

我成功解决此问题的方法是卸载我想要使用的 Python 版本,然后再使用以下命令重新安装它:

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

然后为了激活正确的版本,我需要运行:

pyenv rehash

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接