11

I would like to make a Mac executable for my Python code but always got this error message:

OSError: Python library not found: .Python, libpython3.5.dylib, Python

Both PyInstaller and py2app returned the same error. What should I do to overcome this problem?

mawgumelar
  • 131
  • 1
  • 5
  • I'm working on figuring out a similar problem, but it would appear that Anaconda installs libpython3.6m.dylib (note the 'm'), which is just a build option when compiling Python. I tried just creating a symlink to overcome this but my project still failed to build so I'm guessing this is why. Not sure where to go next though. – jamzsabb Apr 12 '17 at 19:57
  • 1
    @jamzsabb You are right. The 'm' matters, and now my project is working fine. – mawgumelar Apr 27 '17 at 02:58
  • Glad it worked for you, I gave up trying to build what I was building. Did you download another package or just symlink like I tried? – jamzsabb Apr 28 '17 at 15:24
  • 1
    @jamzsabb No, I did not download any other package. I just created the executable using PyInstaller, py2app, or cxfreeze and then modified its Info.plist, changing libpython3.5.dylib to libpython3.5m.dylib. – mawgumelar Apr 29 '17 at 15:38
  • it's py2app that is failing to build when I get this error actually haha. It wasn't anything important luckily, just trying to build Spyder even though my current job mostly uses R. – jamzsabb Apr 30 '17 at 19:30
  • Hi! I've run into the same problem as you and the same 'm' issue that @jamzsabb mentioned. Where exactly was this info.plist file that you modified? And what inside exactly did you modify? – Aditya Shukla Apr 30 '21 at 18:27

1 Answers1

5

For Mac, try rebuild python to generated shared lib using:

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.5.x

as said in pyenv offical doc

in which 3.5.x is version of python which you are using

For my here, after reinstall python:

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

the dylib located in

~/.pyenv/versions/3.8.0/Python.framework/Versions/3.8/lib/libpython3.8.dylib

which is soft link to 3.4MB file:

~/.pyenv/versions/3.8.0/Python.framework/Versions/3.8/Python

crifan
  • 8,424
  • 1
  • 45
  • 35