Skip to content Skip to sidebar Skip to footer

Pyinstaller On Mac Can't Find Libpython2.7

I am trying to make a binary version of a Python script using PyInstaller 2.0. I am using a basic 'hello world' tkinter script but imported a few dependencies that i need for a pro

Solution 1:

If you are using python via pyenv like me, you might need to reinstall with enabling shared to access xcode libs unless you had done that earlier.

sudo env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 2.7

PS: I am on Darwin but still enable-shared worked than enable-framework

In fact the message below error tells what to do

enter image description here

Solution 2:

Firstly, I see you are using conda. I ran into the exact same issue on Mac, specifically:

ERROR: Can notfindpath ./libpython2.7.dylib

trying to deploy an app I put together in a conda environment.

After a lot of Googling and reading, I found that the current PyInstaller does not handle dynamic libraries with @rpath references very well. You can confirm that the library reference uses @rpath by running "otool -L" on the Python binary, which for you looks like //anaconda/bin/python (might be a link to //anaconda/bin/python2.7).

Fortunately, this was recently addressed on a fork of PyInstaller for conda. The specific patch is at https://github.com/conda-forge/pyinstaller-feedstock/pull/2

What I did to use this forked version is uninstall PyInstaller that I had downloaded in my conda environment via pip, and then used the instructions from https://github.com/conda-forge/pyinstaller-feedstock to use this fork of PyInstaller in my conda environment. Specifically, these commands:

conda config--add channels conda-forge
conda install pyinstaller

So I'd recommend switching to this patched version of PyInstaller specifically for conda environments, and see if you it helps you get past the problem like it did for me.

Post a Comment for "Pyinstaller On Mac Can't Find Libpython2.7"