====== Python ====== ===== Sammlung ===== * https://anvil.works/ --> mit Python WebApps entwickeln * https://coverage.readthedocs.io/ CodeCoverage Messung * grafische Darstellung des Codes: https://bhavaniravi.com/blog/generate-uml-diagrams-from-python-code/ * QR Codes mit Logo https://python.plainenglish.io/using-python-to-create-a-qr-code-from-a-logo-caf5b631f83f * Bei Verwendung von ''from matplotlib import pyplot as plt '' kommt "//Unable to import Axes3D. This may be due to multiple versions of Matplotlib being installed (e.g. as a system package and as a pip package). As a result, the 3D projection is not available. warnings.warn("Unable to import Axes3D. This may be due to multiple versions of//" * Lösung( https://stackoverflow.com/posts/52260859/) global und local installierte packages - ''sudo apt-get remove python3-matplotlib'' - ''pip install matplotlib'' ===== venv ===== * ''.venv/bin/activate'' oder ''source venv/bin/activate'' * pip install ... * pip freeze > requirements.txt #zeigt/speichert installierte Packages * refresh * nach https://bodo-schoenfeld.de/eine-virtuelle-umgebung-fuer-python-erstellen/ bzw. https://realpython.com/python-virtual-environments-a-primer/ * Workflow: * Vorbereiten, installieren: ''sudo pip3 install virtualenv'' oder ''sudo apt install python3-venv'' * Umgebung im Projektordner erstellen: ''virtualenv venv'' oder ''python3 -m venv ./venv'' * Umgebung mit vorhendenen packages anlegen: ''python3 -m venv venv --system-site-packages'' * Pip beim Anlegen aktualisieren: ''python3 -m venv venv --upgrade-deps'' * aktivieren der Umgebung ''source venv/bin/activate'' * arbeiten und ggf. Module installieren mit ''pip3'' bzw. ''python -m pip install '' * anzeigen der module mit ''pip3 freeze > requirements.txt'' oder ''python -m pip freeze > requirements.txt'' und neu installieren: ''python -m pip install -r requirements.txt'' * das speichert aber nicht reproduzierbar die python version und packages version!, besser: siehe unten! * anzeigen welche Versionen von packages installiert sind: ''python3 -m pip list'' * deaktivieren: ''deactivate'' * Genaue, deterministische Reproduzierbarkeit von VENVs mittels ''pip-compile'' https://pip-tools.readthedocs.io/en/latest/#example-usage-for-pip-compile * in der aktiven Umgebung installieren: ''python -m pip install pip-tools'' * ''python -m pip freeze > requirements.in'' * ''pip-compile requirements.in'' * zum Installieren der Abhängigkeiten (in requrirements.txt): ''pip-sync'' ===== JuPyterlab ===== * Installation: ''pip3 install jupyterlab'' * Start: ''jupyter-lab'' * Plugins: * [[https://rise.readthedocs.io/en/stable/|RISE]] - Als Präsendationsfolien darstellen: ''pip3 install RISE'' (Aktuell nur für das alte Notebook https://rise.readthedocs.io/en/stable/usage.html#jupyterlab https://github.com/damianavila/RISE/issues/270 ) * Viele Beispiel-Notepads: https://github.com/nsadawi?tab=repositories ===== KI/ML ===== * https://open.hpi.de/courses/kieinstieg2020 * https://open.hpi.de/courses/kipraxis2021/ * Buch https://raw.githubusercontent.com/abhishekkrthakur/approachingalmost/master/AAAMLP.pdf ===== OpenCV ===== * https://www.pyimagesearch.com/2018/09/19/pip-install-opencv/ * https://emanual.robotis.com/docs/en/platform/turtlebot3/appendix_raspi_cam/ Erkennung von OBjekt mit Position und Ausrichtung: https://youtu.be/AyZ5lcz5IzM?t=87 * pyzbar https://github.com/NaturalHistoryMuseum/pyzbar/issues/57 https://stackoverflow.com/questions/48287816/obtaining-location-of-qr-code-using-pyzbar ===== Nützliche Erweiterungen ===== * Parameter von der Kommandozeile einlesen * https://realpython.com/command-line-interfaces-python-argparse/ * Automatische Formatierung mit Black * Installation von https://black.readthedocs.io/en/latest/ * ''pip install black'' - ''black script.py'' Aufruf über Kommandozeile - oder über Kontext/Plugin in IDE pyCharm - externes Tool anlegen mit Pfad zu ''which black'', und in https://plugins.jetbrains.com/plugin/7177-file-watchers anlegen - oder in https://plugins.jetbrains.com/plugin/14321-blackconnect/ eintragen und mit Autostart starten * pip3 install aiohttp aiohttp_cors blackd * mit Plugin https://plugins.jetbrains.com/plugin/14321-blackconnect * blackd in autostart eintragen * Flussdiagramm aus Python machen, oder für einzelne Funktion: https://pypi.org/project/pyflowchart/ --> * ''pip install pyflowchart'' * ''python -m pyflowchart example.py'' oder ''python -m pyflowchart example.py -f main'' * ToDo: * https://github.com/wemake-services/wemake-python-styleguide * https://realpython.com/tutorials/api/