Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS X: can't find the python library [$30 awarded] #443

Closed
ThomasWaldmann opened this issue Sep 20, 2015 · 10 comments
Closed

OS X: can't find the python library [$30 awarded] #443

ThomasWaldmann opened this issue Sep 20, 2015 · 10 comments
Labels

Comments

@ThomasWaldmann
Copy link
Contributor

ThomasWaldmann commented Sep 20, 2015

I'ld like to use pyinstaller 3 on OS X to build a single-file executable for borgbackup.

When trying to do that, it says it can't find the python library (usually it is named libpython3.4.dylib).

I did look around myself, but I also could not find it. Is there a special reason why it is not there after installing python 3.4.3?

This is on OS X Yosemite and I installed python with pyenv install 3.4.3 + pyenv global 3.4.3.

--- The **[$30 bounty](https://www.bountysource.com/issues/26821395-os-x-can-t-find-the-python-library?utm_campaign=plugin&utm_content=tracker%2F282009&utm_medium=issues&utm_source=github)** on this issue has been claimed at [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F282009&utm_medium=issues&utm_source=github).
@yyuu yyuu changed the title OS X: can't find the python library OS X: can't find the python library [$30] Sep 20, 2015
@yyuu yyuu added the bounty label Sep 20, 2015
@yyuu
Copy link
Contributor

yyuu commented Sep 21, 2015

I installed pyinstaller 67a5f8d into pyenv built 3.4.3. (I couldn't install pyinstaller to 3.4.3 via PyPI)

% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.10.5
BuildVersion:   14F27
% pyenv version
3.4.3 (set by /Users/yyuu/.pyenv/version)
% git clone https://github.com/pyinstaller/pyinstaller.git
Cloning into 'pyinstaller'...
remote: Counting objects: 26946, done.
remote: Compressing objects: 100% (356/356), done.
remote: Total 26946 (delta 214), reused 0 (delta 0), pack-reused 26589
Receiving objects: 100% (26946/26946), 28.81 MiB | 2.64 MiB/s, done.
Resolving deltas: 100% (19474/19474), done.
Checking connectivity... done.
% git describe
3.0.dev2-31-g67a5f8d
% python setup.py install
running install
running bdist_egg
running egg_info
creating PyInstaller.egg-info
writing PyInstaller.egg-info/PKG-INFO
writing entry points to PyInstaller.egg-info/entry_points.txt
writing top-level names to PyInstaller.egg-info/top_level.txt
writing dependency_links to PyInstaller.egg-info/dependency_links.txt
writing requirements to PyInstaller.egg-info/requires.txt
writing manifest file 'PyInstaller.egg-info/SOURCES.txt'
reading manifest file 'PyInstaller.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
(... snip ...)
Installing pyi-archive_viewer script to /Users/yyuu/.pyenv/versions/3.4.3/bin
Installing pyi-bindepend script to /Users/yyuu/.pyenv/versions/3.4.3/bin
Installing pyi-makespec script to /Users/yyuu/.pyenv/versions/3.4.3/bin
Installing pyi-grab_version script to /Users/yyuu/.pyenv/versions/3.4.3/bin
Installing pyi-set_version script to /Users/yyuu/.pyenv/versions/3.4.3/bin
Installing pyinstaller script to /Users/yyuu/.pyenv/versions/3.4.3/bin
Installing pyi-pprint_toc script to /Users/yyuu/.pyenv/versions/3.4.3/bin

Installed /Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg
Processing dependencies for PyInstaller==3.0.dev3+67a5f8d
Searching for setuptools==18.3.2
Best match: setuptools 18.3.2
Adding setuptools 18.3.2 to easy-install.pth file
Installing easy_install-3.4 script to /Users/yyuu/.pyenv/versions/3.4.3/bin
Installing easy_install script to /Users/yyuu/.pyenv/versions/3.4.3/bin

Using /Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages
Finished processing dependencies for PyInstaller==3.0.dev3+67a5f8d
% pyenv rehash

I confirmed the reproduction of the build error on OS X, and I also confirmed it's working on Debian GNU/Linux amd64.

% pyinstaller hello.py
27 INFO: PyInstaller: 3.0.dev3+67a5f8d
27 INFO: Python: 3.4.3
35 INFO: Platform: Darwin-14.5.0-x86_64-i386-64bit
36 INFO: wrote /Users/yyuu/pyi/hello.spec
36 WARNING: You are running 64-bit Python: created binaries will only work on Mac OS X 10.6+.
If you need 10.4-10.5 compatibility, run Python as a 32-bit binary with this command:

    VERSIONER_PYTHON_PREFER_32_BIT=yes arch -i386 /Users/yyuu/.pyenv/versions/3.4.3/bin/python

1042 INFO: UPX is not available.
1043 INFO: Extending PYTHONPATH with /Users/yyuu/pyi
1043 INFO: checking Analysis
1043 INFO: Building Analysis because out00-Analysis.toc is non existent
1044 INFO: Initializing module dependency graph...
1045 INFO: Looking for graph hooks ...
1046 INFO: Analyzing base_library.zip ...
4168 INFO: running Analysis out00-Analysis.toc
4176 INFO: Analyzing /Users/yyuu/pyi/hello.py
4179 INFO: Looking for import hooks ...
4181 INFO: Processing hook   hook-encodings.py
4189 INFO: Processing hook   hook-xml.py
4427 INFO: Processing hook   hook-distutils.py
4430 INFO: Processing hook   hook-pydoc.py
4430 INFO: Processing hook   hook-xml.sax.py
4442 INFO: Looking for ctypes DLLs
4442 INFO: Analyzing run-time hooks ...
4450 INFO: Looking for dynamic libraries
4527 INFO: Looking for eggs
4527 INFO: Python library not in binary depedencies. Doing additional searching...
Traceback (most recent call last):
  File "/Users/yyuu/.pyenv/versions/3.4.3/bin/pyinstaller", line 9, in <module>
    load_entry_point('PyInstaller==3.0.dev3+67a5f8d', 'console_scripts', 'pyinstaller')()
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/__main__.py", line 99, in run
    run_build(opts, spec_file, pyi_config)
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/__main__.py", line 47, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **opts.__dict__)
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/building/build_main.py", line 732, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/building/build_main.py", line 675, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/building/build_main.py", line 205, in __init__
    self.__postinit__()
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/building/datastruct.py", line 153, in __postinit__
    self.assemble()
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/building/build_main.py", line 503, in assemble
    self._check_python_library(self.binaries)
  File "/Users/yyuu/.pyenv/versions/3.4.3/lib/python3.4/site-packages/PyInstaller-3.0.dev3+67a5f8d-py3.4.egg/PyInstaller/building/build_main.py", line 568, in _check_python_library
    raise IOError(msg)
OSError: Python library not found! This usually happens on Debian/Ubuntu
where you need to install Python library:

  apt-get install python3-dev
  apt-get install python-dev


@yyuu
Copy link
Contributor

yyuu commented Sep 21, 2015

It's apparently failing to find libpython3.4.dylib.

https://github.com/pyinstaller/pyinstaller/blob/67a5f8d577fe77922ca881d7277d795f569e4ed9/PyInstaller/building/build_main.py#L555-L568
https://github.com/pyinstaller/pyinstaller/blob/67a5f8d577fe77922ca881d7277d795f569e4ed9/PyInstaller/depend/bindepend.py#L834-L851

By default of CPython (and pyenv), the python executable will be generated as static linked and libpython*.dylib will not be generated. I confirmed that rebuilding CPython 3.4.3 with enabling framework support (env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.4.3) solves the issue with PyInstaller.

@ThomasWaldmann Could you check if you don't have ${PYENV_ROOT}/versions/3.4.3/Python.framework? If so, please rebuild your 3.4.3 with --enable-framework and try running PyInstaller again.

@ThomasWaldmann
Copy link
Contributor Author

Giving the env variable worked! Thanks for helping with that!

BTW, are there some docs where this trick could be added? Guess I am not the only one who might need that.

@yyuu
Copy link
Contributor

yyuu commented Sep 22, 2015

I realized that PyInstaller installed into pyenv built 3.4.3 was using libpython3.4.so.1 from /usr/lib/x86_64-linux-gnu (shared object of system python) on Debian GNU/Linux. It seems that current impl of PyInstaller requires CPython built with --enable-shared (or, --enable-framework on OS X).

I'll update document about how we can build CPython with enabling shared.

@yyuu
Copy link
Contributor

yyuu commented Sep 22, 2015

Opened a PR of pyinstaller/pyinstaller#1510 to improve PyInstaller's error message.

@yyuu
Copy link
Contributor

yyuu commented Sep 22, 2015

Updated Wiki of both PyInstaller and pyenv.

@yyuu
Copy link
Contributor

yyuu commented Sep 22, 2015

I believe that there are no tasks remaining now.

@ThomasWaldmann
Copy link
Contributor Author

Great work, thanks!

@PraneethKarnena
Copy link

It's apparently failing to find libpython3.4.dylib.

https://github.com/pyinstaller/pyinstaller/blob/67a5f8d577fe77922ca881d7277d795f569e4ed9/PyInstaller/building/build_main.py#L555-L568
https://github.com/pyinstaller/pyinstaller/blob/67a5f8d577fe77922ca881d7277d795f569e4ed9/PyInstaller/depend/bindepend.py#L834-L851

By default of CPython (and pyenv), the python executable will be generated as static linked and libpython*.dylib will not be generated. I confirmed that rebuilding CPython 3.4.3 with enabling framework support (env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.4.3) solves the issue with PyInstaller.

@ThomasWaldmann Could you check if you don't have ${PYENV_ROOT}/versions/3.4.3/Python.framework? If so, please rebuild your 3.4.3 with --enable-framework and try running PyInstaller again.

Fixed. Many thanks!

@1imran
Copy link

1imran commented Feb 15, 2022

@ThomasWaldmann Could you check if you don't have ${PYENV_ROOT}/versions/3.4.3/Python.framework? If so, please rebuild your 3.4.3 with --enable-framework and try running PyInstaller again.

Verified by checking for presence of Python.framework folder at (in my case I was dealing with v3.9.1):
${PYENV_ROOT}/versions/3.9.1/Library/Frameworks/Python.framework

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants