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

Pyinstaller fails to build using Deadsnakes Ubuntu PPA #6358

Closed
3 of 6 tasks
johnthagen opened this issue Nov 8, 2021 · 3 comments
Closed
3 of 6 tasks

Pyinstaller fails to build using Deadsnakes Ubuntu PPA #6358

johnthagen opened this issue Nov 8, 2021 · 3 comments
Labels
triage Please triage and relabel this issue

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Nov 8, 2021

Description of the issue

When building on Ubuntu 18.04 using the Deadsnakes PPA to allow for usage of Python 3.9, Pyinstaller fails to build.

This is related to #5669, as one potential way to use newer Python versions targeting an older GLIBC (without needing to build Python from source).

Context information (for bug reports)

  • Output of pyinstaller --version: 4.6

  • Version of Python: 3.9.7

  • Platform: ubuntu:18.04 Docker Image

  • How you installed Python: Deadsnakes PPA

  • Did you also try this on another platform? Does it work there?

  • try the latest development version, using the following command:

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

Make sure everything is packaged correctly

  • start with clean installation
  • use the latest development version
  • Run your frozen program from a command window (shell) — instead of double-clicking on it
  • Package your program in --onedir mode
  • Package without UPX, say: use the option --noupx or set upx=False in your .spec-file
  • Repackage you application in verbose/debug mode. For this, pass the option --debug to pyi-makespec or pyinstaller or use EXE(..., debug=1, ...) in your .spec file.

A minimal example program which shows the error

# main.py
print("Hello World")

Note, how to install pip for Deadsnakes: https://www.youtube.com/watch?v=2Hg5-Hrsa6w

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y python3.9 python3.9-dev python3.9-venv
RUN python3.9 -m venv /venv

COPY main.py .

RUN export PATH=/venv/bin:$PATH; python -m pip install --upgrade pip && \
  python -m pip install pyinstaller && \
  pyinstaller --onefile main.py

Stacktrace / full error message

$ docker build --no-cache .
 > [7/7] RUN export PATH=/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; python -m pip install --upgrade pip &&   python -m pip install pyinstaller &&   pyinstaller --onefile main.py:                                                                   
#11 0.486 Requirement already satisfied: pip in /venv/lib/python3.9/site-packages (21.2.3)                                               
#11 0.936 Collecting pip                                                                                                                 
#11 1.403   Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)                                                                             
#11 2.358 Installing collected packages: pip
#11 2.358   Attempting uninstall: pip
#11 2.358     Found existing installation: pip 21.2.3
#11 2.459     Uninstalling pip-21.2.3:
#11 2.593       Successfully uninstalled pip-21.2.3
#11 3.429 Successfully installed pip-21.3.1
#11 4.292 Collecting pyinstaller
#11 4.635   Downloading pyinstaller-4.6-py3-none-manylinux2014_x86_64.whl (1.5 MB)
#11 5.959 Requirement already satisfied: setuptools in /venv/lib/python3.9/site-packages (from pyinstaller) (57.4.0)
#11 6.101 Collecting altgraph
#11 6.337   Downloading altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
#11 6.430 Collecting pyinstaller-hooks-contrib>=2020.6
#11 6.500   Downloading pyinstaller_hooks_contrib-2021.3-py2.py3-none-any.whl (200 kB)
#11 6.644 Installing collected packages: pyinstaller-hooks-contrib, altgraph, pyinstaller
#11 7.040 Successfully installed altgraph-0.17.2 pyinstaller-4.6 pyinstaller-hooks-contrib-2021.3
#11 7.213 33 INFO: PyInstaller: 4.6
#11 7.213 33 INFO: Python: 3.9.7
#11 7.216 35 INFO: Platform: Linux-5.10.47-linuxkit-x86_64-with-glibc2.27
#11 7.216 36 INFO: wrote /main.spec
#11 7.219 39 INFO: UPX is not available.
#11 7.221 40 INFO: Extending PYTHONPATH with paths
#11 7.221 ['/']
#11 7.316 135 INFO: checking Analysis
#11 7.316 136 INFO: Building Analysis because Analysis-00.toc is non existent
#11 7.317 136 INFO: Initializing module dependency graph...
#11 7.318 137 INFO: Caching module graph hooks...
#11 7.323 143 INFO: Analyzing base_library.zip ...
#11 9.025 1844 INFO: Processing pre-find module path hook distutils from '/venv/lib/python3.9/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
#11 9.026 1845 INFO: distutils: retargeting to non-venv dir '/usr/lib/python3.9'
#11 11.06 3880 INFO: Caching module dependency graph...
#11 11.16 3982 INFO: running Analysis Analysis-00.toc
#11 11.19 4005 INFO: Analyzing /main.py
#11 11.19 4007 INFO: Processing module hooks...
#11 11.19 4008 INFO: Loading module hook 'hook-lib2to3.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.19 4014 INFO: Loading module hook 'hook-xml.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.22 4042 INFO: Loading module hook 'hook-distutils.util.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.22 4044 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.23 4045 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.23 4045 INFO: Loading module hook 'hook-sysconfig.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.23 4050 INFO: Loading module hook 'hook-distutils.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.23 4051 INFO: Loading module hook 'hook-heapq.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.23 4052 INFO: Loading module hook 'hook-pickle.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.23 4053 INFO: Loading module hook 'hook-encodings.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.27 4092 INFO: Loading module hook 'hook-difflib.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 11.28 4100 INFO: Looking for ctypes DLLs
#11 11.30 4118 INFO: Analyzing run-time hooks ...
#11 11.30 4122 INFO: Including run-time hook '/venv/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py'
#11 11.30 4124 INFO: Including run-time hook '/venv/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
#11 11.31 4126 INFO: Including run-time hook '/venv/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py'
#11 11.31 4131 INFO: Looking for dynamic libraries
#11 11.55 4373 INFO: Looking for eggs
#11 11.55 4373 INFO: Python library not in binary dependencies. Doing additional searching...
#11 11.57 Traceback (most recent call last):
#11 11.57   File "/venv/bin/pyinstaller", line 8, in <module>
#11 11.57     sys.exit(run())
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/__main__.py", line 124, in run
#11 11.57     run_build(pyi_config, spec_file, **vars(args))
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/__main__.py", line 58, in run_build
#11 11.57     PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 782, in main
#11 11.57     build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 714, in build
#11 11.57     exec(code, spec_namespace)
#11 11.57   File "/main.spec", line 7, in <module>
#11 11.57     a = Analysis(['main.py'],
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 277, in __init__
#11 11.57     self.__postinit__()
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 155, in __postinit__
#11 11.57     self.assemble()
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 501, in assemble
#11 11.57     self._check_python_library(self.binaries)
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 605, in _check_python_library
#11 11.57     python_lib = bindepend.get_python_library_path()
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/depend/bindepend.py", line 897, in get_python_library_path
#11 11.57     python_libname = findLibrary(name)
#11 11.57   File "/venv/lib/python3.9/site-packages/PyInstaller/depend/bindepend.py", line 775, in findLibrary
#11 11.58     lib = _which_library(name, paths)
#11 11.58   File "/venv/lib/python3.9/site-packages/PyInstaller/depend/bindepend.py", line 806, in _which_library
#11 11.58     for _path in os.listdir(path):
#11 11.58 FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib64'
------
executor failed running [/bin/sh -c export PATH=/venv/bin:$PATH; python -m pip install --upgrade pip &&   python -m pip install pyinstaller &&   pyinstaller --onefile main.py]: exit code: 1

Please also see https://github.com/pyinstaller/pyinstaller/wiki/How-to-Report-Bugs
for more about what would use to solve the issue.

@johnthagen johnthagen added the triage Please triage and relabel this issue label Nov 8, 2021
@johnthagen
Copy link
Contributor Author

Latest development version results in different output:

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y python3.9 python3.9-dev python3.9-venv
RUN python3.9 -m venv /venv

COPY main.py .

RUN export PATH=/venv/bin:$PATH; python -m pip install --upgrade pip && \
  python -m pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip && \
  pyinstaller --onefile main.py
 > [7/7] RUN export PATH=/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; python -m pip install --upgrade pip &&   python -m pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip &&   pyinstaller --onefile main.py:                
#11 0.474 Requirement already satisfied: pip in /venv/lib/python3.9/site-packages (21.2.3)                                               
#11 0.799 Collecting pip                                                                                                                 
#11 1.260   Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)                                                                             
#11 2.359 Installing collected packages: pip
#11 2.359   Attempting uninstall: pip
#11 2.359     Found existing installation: pip 21.2.3
#11 2.458     Uninstalling pip-21.2.3:
#11 2.599       Successfully uninstalled pip-21.2.3
#11 3.419 Successfully installed pip-21.3.1
#11 4.014 Collecting https://github.com/pyinstaller/pyinstaller/archive/develop.zip
#11 5.835   Downloading https://github.com/pyinstaller/pyinstaller/archive/develop.zip
#11 7.877   Installing build dependencies: started
#11 11.64   Installing build dependencies: finished with status 'done'
#11 11.65   Getting requirements to build wheel: started
#11 11.80   Getting requirements to build wheel: finished with status 'done'
#11 11.80   Preparing metadata (pyproject.toml): started
#11 12.00   Preparing metadata (pyproject.toml): finished with status 'done'
#11 12.42 Collecting altgraph
#11 12.77   Downloading altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
#11 12.82 Requirement already satisfied: setuptools in /venv/lib/python3.9/site-packages (from pyinstaller==5.0.dev0) (57.4.0)
#11 13.06 Collecting pyinstaller-hooks-contrib>=2020.6
#11 13.18   Downloading pyinstaller_hooks_contrib-2021.3-py2.py3-none-any.whl (200 kB)
#11 13.35 Building wheels for collected packages: pyinstaller
#11 13.35   Building wheel for pyinstaller (pyproject.toml): started
#11 14.03   Building wheel for pyinstaller (pyproject.toml): finished with status 'done'
#11 14.03   Created wheel for pyinstaller: filename=pyinstaller-5.0.dev0-py3-none-any.whl size=2691385 sha256=a03eb5d3c559faeeff9e065febd1404107330c67a7f6576f0f46cd071e439d0f
#11 14.03   Stored in directory: /tmp/pip-ephem-wheel-cache-pvy7v00w/wheels/39/c0/2a/3eb6f61d427d961cd8a2d9e378a8c743147b175d79f092cf24
#11 14.04 Successfully built pyinstaller
#11 14.05 Installing collected packages: pyinstaller-hooks-contrib, altgraph, pyinstaller
#11 14.47 Successfully installed altgraph-0.17.2 pyinstaller-5.0.dev0 pyinstaller-hooks-contrib-2021.3
#11 14.70 30 INFO: PyInstaller: 5.0.dev0
#11 14.70 30 INFO: Python: 3.9.7
#11 14.70 32 INFO: Platform: Linux-5.10.47-linuxkit-x86_64-with-glibc2.27
#11 14.71 33 INFO: wrote /main.spec
#11 14.71 35 INFO: UPX is not available.
#11 14.71 36 INFO: Extending PYTHONPATH with paths
#11 14.71 ['/']
#11 14.82 143 INFO: checking Analysis
#11 14.82 143 INFO: Building Analysis because Analysis-00.toc is non existent
#11 14.82 143 INFO: Initializing module dependency graph...
#11 14.82 144 INFO: Caching module graph hooks...
#11 14.82 150 INFO: Analyzing base_library.zip ...
#11 16.77 2101 INFO: Processing pre-find module path hook distutils from '/venv/lib/python3.9/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
#11 16.77 2102 INFO: distutils: retargeting to non-venv dir '/usr/lib/python3.9'
#11 18.14 3464 INFO: Caching module dependency graph...
#11 18.23 3560 INFO: running Analysis Analysis-00.toc
#11 18.26 3583 INFO: Analyzing /main.py
#11 18.26 3585 INFO: Processing module hooks...
#11 18.26 3585 INFO: Loading module hook 'hook-lib2to3.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.26 3592 INFO: Loading module hook 'hook-xml.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.30 3622 INFO: Loading module hook 'hook-distutils.util.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.30 3624 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.30 3625 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.30 3626 INFO: Loading module hook 'hook-sysconfig.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.30 3631 INFO: Loading module hook 'hook-distutils.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.30 3631 INFO: Loading module hook 'hook-heapq.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.31 3632 INFO: Loading module hook 'hook-pickle.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.31 3633 INFO: Loading module hook 'hook-encodings.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.34 3669 INFO: Loading module hook 'hook-difflib.py' from '/venv/lib/python3.9/site-packages/PyInstaller/hooks'...
#11 18.35 3676 INFO: Looking for ctypes DLLs
#11 18.37 3694 INFO: Analyzing run-time hooks ...
#11 18.37 3698 INFO: Including run-time hook '/venv/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py'
#11 18.37 3700 INFO: Including run-time hook '/venv/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
#11 18.38 3702 INFO: Including run-time hook '/venv/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py'
#11 18.38 3707 INFO: Looking for dynamic libraries
#11 18.74 4068 INFO: Looking for eggs
#11 18.74 4068 INFO: Python library not in binary dependencies. Doing additional searching...
#11 18.76 Traceback (most recent call last):
#11 18.76   File "/venv/bin/pyinstaller", line 8, in <module>
#11 18.76     sys.exit(run())
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/__main__.py", line 124, in run
#11 18.76     run_build(pyi_config, spec_file, **vars(args))
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/__main__.py", line 58, in run_build
#11 18.76     PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 818, in main
#11 18.76     build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 750, in build
#11 18.76     exec(code, spec_namespace)
#11 18.76   File "/main.spec", line 7, in <module>
#11 18.76     a = Analysis(
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 302, in __init__
#11 18.76     self.__postinit__()
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 155, in __postinit__
#11 18.76     self.assemble()
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 537, in assemble
#11 18.76     self._check_python_library(self.binaries)
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 641, in _check_python_library
#11 18.76     python_lib = bindepend.get_python_library_path()
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/depend/bindepend.py", line 897, in get_python_library_path
#11 18.76     python_libname = findLibrary(name)
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/depend/bindepend.py", line 788, in findLibrary
#11 18.76     return os.path.join(dir, _get_so_name(lib))
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/depend/bindepend.py", line 830, in _get_so_name
#11 18.76     m = re.search(pattern, compat.exec_command(*cmd))
#11 18.76   File "/venv/lib/python3.9/site-packages/PyInstaller/compat.py", line 339, in exec_command
#11 18.76     proc = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, **kwargs)
#11 18.76   File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
#11 18.76     self._execute_child(args, executable, preexec_fn, close_fds,
#11 18.76   File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
#11 18.76     raise child_exception_type(errno_num, err_msg, err_filename)
#11 18.76 FileNotFoundError: [Errno 2] No such file or directory: 'objdump'

@rokm
Copy link
Member

rokm commented Nov 8, 2021

The error in first report is due to #6331.

The error in second report is due to binutils not being installed.

@johnthagen
Copy link
Contributor Author

johnthagen commented Nov 8, 2021

@rokm Thanks! An updated Dockerfile for anyone else that finds this searching for deadsnakes:

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y software-properties-common binutils
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y python3.9 python3.9-dev python3.9-venv
RUN python3.9 -m venv /venv --upgrade-deps

COPY main.py .

RUN export PATH=/venv/bin:$PATH; python -m pip install pyinstaller && \
  pyinstaller --onefile main.py

bwoodsend added a commit to bwoodsend/pyinstaller that referenced this issue Nov 10, 2021
Legorooj added a commit that referenced this issue Nov 10, 2021
* Windows: Catch/re-raise failure to load win32ctypes under -OO.

  PyInstaller can no longer run under Python's optimised mode due to the
  dependency chain PyInstaller -> win32ctypes -> cffi -> pycparser which
  has started using/ Yacc which interprets grammars from docstrings.

* Docs: Remove running with optimisations section (#6345).

  Running with -OO no longer works on Windows, makes such an insignificant
  difference to the overall output size and as generally agreed to be more trouble
  than it's worth.

* Linux: Explicitly check that binutils tools are available.

  This should catch issues like:
  #6358 (comment)

* Abort build if any obsolete stdlib backports are installed.

  Most prominently, check for `enum34` - the backport of `enum` - which masks the
  stdlib variant causing  issues like #5728.

Co-authored-by: Jasper Harrison <legorooj@protonmail.com>
Legorooj added a commit that referenced this issue Nov 10, 2021
* Windows: Catch/re-raise failure to load win32ctypes under -OO.

  PyInstaller can no longer run under Python's optimised mode due to the
  dependency chain PyInstaller -> win32ctypes -> cffi -> pycparser which
  has started using/ Yacc which interprets grammars from docstrings.

* Docs: Remove running with optimisations section (#6345).

  Running with -OO no longer works on Windows, makes such an insignificant
  difference to the overall output size and as generally agreed to be more trouble
  than it's worth.

* Linux: Explicitly check that binutils tools are available.

  This should catch issues like:
  #6358 (comment)

* Abort build if any obsolete stdlib backports are installed.

  Most prominently, check for `enum34` - the backport of `enum` - which masks the
  stdlib variant causing  issues like #5728.

Co-authored-by: Jasper Harrison <legorooj@protonmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage Please triage and relabel this issue
Projects
None yet
Development

No branches or pull requests

2 participants