Python Forum
how to compile a stand alone executable on linux?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to compile a stand alone executable on linux?
#1
Iv made a few little programs that i use on my comp (Linux/Manjaro) but they all show up in the running process list as just "Python" , on windows i would just compile them with py2exe and they would run as .exe's and show as themselves under the process list.

Iv tried pyinstaller but i cant get it to install/work? (see below).

Also tried py_compile which does create a .pyc under __pycache__/ but it wont run with ./mycode.pyc and if i use pythpn mycode.pyc then it just shows up as a "python" process again instead on "mycode" or "mycode.pyc".

It must be that i'm missing something really simple cos i'm a dumb ass noob but i cant figure it.

P.S. i'm not really talking about making an installation package, i have not got that far yet on linux.



pyinstaller problems (BASH CODE):-
❰greg❙~/PycharmProjects/octo-notifier-working❱✔≻ pyinstaller octo-notifier.py 
Traceback (most recent call last):
  File "/usr/bin/pyinstaller", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3147, in <module>
    @_call_aside
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3131, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3160, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 666, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 984, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 870, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'macholib>=1.8' distribution was not found and is required by PyInstaller
So i try to install aur/python-macholib 1.9-1 (BASH CODE):-

Traceback (most recent call last):
  File "setup.py", line 532, in <module>
    use_setuptools()
  File "setup.py", line 433, in use_setuptools
    return _do_download(os.path.abspath(os.curdir))
  File "setup.py", line 420, in _do_download
    tarball = download_setuptools(packagename, to_dir)
  File "setup.py", line 443, in download_setuptools
    chksum, url = get_pypi_src_download(packagename)
  File "setup.py", line 317, in get_pypi_src_download
    raise RuntimeError("Cannot determine downlink link for %s"%(package,))
RuntimeError: Cannot determine downlink link for setuptools
==> ERROR: A failure occurred in package_python2-macholib().
    Aborting...
==> ERROR: Makepkg was unable to build python-macholib.
Way out of my depth now
Reply
#2
well i got a bit further. I managed to install pyinstaller via pip but after compiling my app with it then and trying to run my app i get a nice new error?

Quote:❰greg❙~/PycharmProjects/octo-notifier-working/pybuilder(git:master)❱✘≻ sudo pip install https://github.com/pyinstaller/pyinstall...ll/develop
[sudo] password for greg:
Collecting https://github.com/pyinstaller/pyinstall...ll/develop
Downloading https://github.com/pyinstaller/pyinstall...ll/develop (3.5MB)
100% |████████████████████████████████| 3.5MB 414kB/s
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from PyInstaller==3.4.dev0+9f4eca801)
Requirement already satisfied: pefile>=2017.8.1 in /usr/lib/python3.6/site-packages (from PyInstaller==3.4.dev0+9f4eca801)
Requirement already satisfied: macholib>=1.8 in /usr/lib/python3.6/site-packages (from PyInstaller==3.4.dev0+9f4eca801)
Requirement already satisfied: future in /usr/lib/python3.6/site-packages (from pefile>=2017.8.1->PyInstaller==3.4.dev0+9f4eca801)
Requirement already satisfied: altgraph>=0.15 in /usr/lib/python3.6/site-packages (from macholib>=1.8->PyInstaller==3.4.dev0+9f4eca801)
Installing collected packages: PyInstaller
Running setup.py install for PyInstaller ... done
Successfully installed PyInstaller-3.4.dev0+9f4eca801

Quote:❰greg❙~/PycharmProjects/octo-notifier-working❱✔≻ sudo pyinstaller octo-notifier-messabout.py
[sudo] password for greg:
36 INFO: PyInstaller: 3.4.dev0+9f4eca801
36 INFO: Python: 3.6.4
37 INFO: Platform: Linux-4.14.24-1-MANJARO-x86_64-with-arch-Manjaro-Linux
37 INFO: wrote /home/greg/PycharmProjects/octo-notifier-working/octo-notifier-messabout.spec
39 INFO: UPX is not available.
39 INFO: Extending PYTHONPATH with paths
['/home/greg/PycharmProjects/octo-notifier-working',
'/home/greg/PycharmProjects/octo-notifier-working']
40 INFO: checking Analysis
45 INFO: checking PYZ
46 INFO: checking PKG
46 INFO: Bootloader /usr/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit/run
46 INFO: checking EXE
47 INFO: checking COLLECT
WARNING: The output directory "/home/greg/PycharmProjects/octo-notifier-working/dist/octo-notifier-messabout" and ALL ITS CONTENTS will be REMOVED! Continue? (y/n)y
5615 INFO: Removing dir /home/greg/PycharmProjects/octo-notifier-working/dist/octo-notifier-messabout
6170 INFO: Building COLLECT out00-COLLECT.toc
6481 INFO: Building COLLECT out00-COLLECT.toc completed successfully.

Quote:❰greg❙~/PycharmProjects/octo-notifier-working/build/octo-notifier-messabout❱✔≻ ./octo-notifier-messabout
[17267] Error loading Python lib '/home/greg/PycharmProjects/octo-notifier-working/build/octo-notifier-messabout/libpython3.6m.so.1.0': dlopen: /home/greg/PycharmProjects/octo-notifier-working/build/octo-notifier-messabout/libpython3.6m.so.1.0: cannot open shared object file: No such file or directory

Dont ask why i'm using sudo for everything, if i dont use it i just get a load of :-

Quote:ldd: warning: you do not have execution permission for `/usr/lib/libgcc_s.so.1'
ldd: warning: you do not have execution permission for `/usr/lib/libacl.so.1'
ldd: warning: you do not have execution permission for `/usr/lib/libkrb5support.so.0'
ldd: warning: you do not have execution permission for `/usr/lib/libhogweed.so.4'

Im probably doing this all wrong but im following examples from the net (as best i can).

I really need some help.
Reply
#3
Probably you need to install python-dev
Read the error message. You are missing a library: libpython3.6m.so.1.0
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
I have libpython3.6m.so.1.0 installed.

Quote:locate libpython3.6m.so.1.0
/usr/lib/libpython3.6m.so.1.0

And i dont see any package called python-dev

Quote:❰greg❙/usr❱✔≻ yaourt -Ss python-dev
❰greg❙/usr❱✘≻

Checking the "dist" folder that was created when i run pyinstaller iv also found that it has already copied libpython3.6m.so.1.0 into it. So it definitely exists and has already used it?

Quote:❰greg❙~/PycharmProjects/octo-notifier-working/dist/octo-notifier-messabout❱✔≻ ls -la libpy*
-rwxr-xr-x 1 root root 3326808 Jan 5 02:36 libpython3.6m.so.1.0*
Reply
#5
I have been advised to try out Nuitka and it works like a charm so for now i shall go with that. Thank you all.

What is Nuitka

The TL;DR ... Nuitka is a Python compiler. It's fully compatible with Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, and 3.6. You feed it your Python app, it does a lot of clever things, and spits out an execut
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,279 May-24-2022, 07:02 AM
Last Post: netanelst
  Stand Alone Python App PadmaDavid 2 1,713 Feb-28-2020, 03:15 PM
Last Post: PadmaDavid
  .py to exe or to executable file for linux Low_Ki_ 4 9,794 Apr-26-2017, 05:59 AM
Last Post: Low_Ki_

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020