# Python

# Python installation mit pip

# Python3 auf MACOS installieren.

### 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 brew den path in den Umgebungsvariablen hinzufügen.  
Im Terminal den Befehl kopieren:

```
Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/<deinbenutzername>/.bash_profile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh
    
    
Also kopieren und ausführen müssen wir mit Klammern:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/<deinbenutzername>/.bash_profile
    eval "$(/opt/homebrew/bin/brew shellenv)"

```

Nun python aus homebrew installieren

```bash
brew install python
```

Nun PIP installieren

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

###   

# python3 auf Windows installieren enthält schon pip

Beschreibung:

Installation python3 und pip

Installtion

1\. Python3 installieren

Python 3 hier runterladen installieren.  
in der Stable Version ist pip schon enthalten

[https://www.python.org/downloads/windows/](https://www.python.org/downloads/windows/)

Nach der installtion die Installation mit Admin rechten nochmals starten und modify auswählen und diese Punkte anhaken  
und auf next klicken

[![01.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/scaled-1680-/0l51kOFrBty7LpUP-01.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/0l51kOFrBty7LpUP-01.png)

Nun diese Punkte anhaken.

[![02.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/scaled-1680-/f7o4YqnLKI0YE4rT-02.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/f7o4YqnLKI0YE4rT-02.png)

Fertig.

Jetz kann mit py oder python in der cmd oder bat python aufgerufen werden.

mit strg+z und dann enter kann der python interpreter verlassen werden, wenn kein script übergeben wurde.

[![03.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/scaled-1680-/F2Dy8apwtH1znazt-03.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/F2Dy8apwtH1znazt-03.png)

möchte man pip nutzen einfach pip eintippen

[![04.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/scaled-1680-/jhdbUDm0Gzo3VvSC-04.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-06/jhdbUDm0Gzo3VvSC-04.png)

fertig

# 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

```bash
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:

<details id="bkmrk-pip-ausgabe-collecti"><summary>pip Ausgabe</summary>

Collecting pyinstaller  
 Downloading pyinstaller-6.7.0-py3-none-win\_amd64.whl.metadata (8.3 kB)  
Collecting setuptools&gt;=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&gt;=2024.6 (from pyinstaller)  
 Downloading pyinstaller\_hooks\_contrib-2024.6-py2.py3-none-any.whl.metadata (16 kB)  
Collecting packaging&gt;=22.0 (from pyinstaller)  
 Downloading packaging-24.0-py3-none-any.whl.metadata (3.2 kB)  
Collecting pefile&gt;=2022.5.30 (from pyinstaller)  
 Downloading pefile-2023.2.7-py3-none-any.whl.metadata (1.4 kB)  
Collecting pywin32-ctypes&gt;=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

</details>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
```