Search code examples
pythonpyinstalleroserror

pyinstaller causes OSerror


I run pyinstaller test.py and got a following error.

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)

I tried brew install python3-dev and brew install python-dev:

==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

I ran following commands but all of them caused the same error: brew reinstall python,PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.0,PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.9.0.

Uninstalling and installing pyinstall didn't work. Does anyone has a clue?

Here's the results of the following commands:

which pyinstaller
/Users/user/.pyenv/shims/pyinstaller
which python
/Users/user/.pyenv/shims/python

Solution

  • I think that pyenv might have failed to install 3.9.0 the second time with the flag you needed.

    The way I got it to work was to uninstall the version of python I wanted to use and then reinstall it with this command:

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

    Then to get the correct version activated, I had to run:

    pyenv rehash
    

    Otherwise, I couldn't get my system to "see" the newly re-installed version.