Hello World in Python mit VS Code und GitHub
Mit diesem Projekt wurde der Einstieg in die GitHub-Welt im Zusammenspiel mit Visual Studio Code (VS Code) und Python ausprobiert. Das Python-Skript ist überraschenderweise ein überschaubares Hello World-Programm.
Voraussetzungen
- Installiertes Python (https://www.python.org/downloads/)
→ Bei der Installation “Add Python to PATH” aktivieren.
- Installiertes Visual Studio Code (https://code.visualstudio.com/)
- Installierte Python-Erweiterung in Visual Studio Code
- Installiertes Git (https://git-scm.com/downloads)
- GitHub-Account (https://github.com)
Projekt in VS Code erstellen
- Einen neuen Ordner anlegen, z. B.:
python-hello-world
- Ordner in Visual Studio Code öffnen (
Datei → Ordner öffnen)
- Neue Datei
hello.py anlegen
- Inhalt einfügen:
print("Hello World")
Python-Interpreter in VS Code auswählen
Strg + Shift + P drücken
- Python: Select Interpreter wählen
- Python 3.x auswählen
Programm ausführen
Entweder aus VS Code oder im Terminal via python hello.py
Repository mit Git initialisieren
Im Terminal von Visual Studio Code ausführen:
git init
git add .
git commit -m "Initial commit"
Repository zu GitHub übertragen
Direkt über Visual Studio Code:
- In VS Code auf Source Control (🔃) klicken
- Button “Publish to GitHub” / “Zu GitHub veröffentlichen” auswählen
- Repository-Namen vergeben
- Privat oder Öffentlich auswählen
→ VS Code legt das Repository automatisch online an.
Ergebnis
https://github.com/hrmnns/python-hello-world