Python als Einzel Executable

Linux

MacOS

Beschreibung:

Ein Python Script als Einzel Executive für MacOS erstellen.
Mit dem Pyinstaller überhaupt kein Problem
Allerding muss das Script auf dem Zielsystem gebaut werden.
Sprich pyinstaller in diesem Fall auch auf dem MAC installiert und ausgeführt werden.

Denn dazu nutzen wir den pip mit pyinstaller.

Vorraussetzung

Python3 auf MACOS installieren.


Homebrew installieren (Eine Repo für Mac)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Nun python aus homebrew installieren

brew install python

Nun PIP installieren

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

Installation pyinstaller

pip install pyinstaller

Umwandeln

pyinstaller		(als eine Datei) (Wenn QT oder tkinter GUI Bibliotheken verwendet werden) (die python Datei)
pyinstaller --onefile --windowed <pythondatei>
pyinstaller --onefile --windowed entschluesseln.py



Icon Einbindung (Funktioniert nur unter Windows und MacOS

optional wenn ein icon mitgegben werden soll
pyinstaller --onefile --windowed --icon=<path_zum_icon_youricon.ico> <pythondatei>
pyinstaller --onefile --windowed  --icon=mein_icon.ico entschluesseln.py

Dann wird ein unterverzsichnis dist erstellt und darin befindet sich dann executable

cd dist/
ls

Ausgabe:

removepermission	removepermission.app


Unsere datei ist die .app für mac



Windows

Beschreibung:

Den pyinstaller gibt auch für Windows um aus einem python script eine Executable zu machen.
Dazu muss python mit pip installiert werden siehe hier :

Installation pyinstaller

Eine cmd / Eingabeaufforderung auf machen und dort

pip install pyinstaller

Dann sieht das ganze so aus:

pip Ausgabe

Collecting pyinstaller
  Downloading pyinstaller-6.7.0-py3-none-win_amd64.whl.metadata (8.3 kB)
Collecting setuptools>=42.0.0 (from pyinstaller)
  Downloading setuptools-70.0.0-py3-none-any.whl.metadata (5.9 kB)
Collecting altgraph (from pyinstaller)
  Downloading altgraph-0.17.4-py2.py3-none-any.whl.metadata (7.3 kB)
Collecting pyinstaller-hooks-contrib>=2024.6 (from pyinstaller)
  Downloading pyinstaller_hooks_contrib-2024.6-py2.py3-none-any.whl.metadata (16 kB)
Collecting packaging>=22.0 (from pyinstaller)
  Downloading packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
Collecting pefile>=2022.5.30 (from pyinstaller)
  Downloading pefile-2023.2.7-py3-none-any.whl.metadata (1.4 kB)
Collecting pywin32-ctypes>=0.2.1 (from pyinstaller)
  Downloading pywin32_ctypes-0.2.2-py3-none-any.whl.metadata (3.8 kB)
Downloading pyinstaller-6.7.0-py3-none-win_amd64.whl (1.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 16.7 MB/s eta 0:00:00
Downloading packaging-24.0-py3-none-any.whl (53 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.5/53.5 kB ? eta 0:00:00
Downloading pefile-2023.2.7-py3-none-any.whl (71 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 71.8/71.8 kB ? eta 0:00:00
Downloading pyinstaller_hooks_contrib-2024.6-py2.py3-none-any.whl (339 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 339.2/339.2 kB 20.6 MB/s eta 0:00:00
Downloading pywin32_ctypes-0.2.2-py3-none-any.whl (30 kB)
Downloading setuptools-70.0.0-py3-none-any.whl (863 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 863.4/863.4 kB 26.7 MB/s eta 0:00:00
Downloading altgraph-0.17.4-py2.py3-none-any.whl (21 kB)
Installing collected packages: altgraph, setuptools, pywin32-ctypes, pefile, packaging, pyinstaller-hooks-contrib, pyinstaller
Successfully installed altgraph-0.17.4 packaging-24.0 pefile-2023.2.7 pyinstaller-6.7.0 pyinstaller-hooks-contrib-2024.6 pywin32-ctypes-0.2.2 setuptools-70.0.0

Nun kann von dem script eine excutable erstellt werden.

pyinstaller		(als eine Datei) (Wenn QT oder tkinter GUI Bibliotheken verwendet werden) (die python Datei)
pyinstaller --onefile --windowed <pythondatei>
pyinstaller --onefile --windowed entschluesseln.py



Icon Einbindung (Funktioniert nur unter Windows und MacOS

optional wenn ein icon mitgegben werden soll
pyinstaller --onefile --windowed --icon=<path_zum_icon_youricon.ico> <pythondatei>
pyinstaller --onefile --windowed  --icon=mein_icon.ico entschluesseln.py

Dann wird ein unterverzsichnis dist erstellt und darin befindet sich dann executable

cd dist/
ls

Ausgabe:

removepermission	removepermission.exe


Unsere datei ist die .exe