====== Python ======
Recommended packages:
^ pipenv | installs packages in a virtual python environment and maintains a Pipfile with all requirements |
===== Requirements / Dependencies =====
* pip
* [[https://pip.pypa.io/en/latest/reference/pip_install/#example-requirements-file|requirements.txt]]
* venv
* pip-tools
* pyenv
* conda
* [[https://pipenv.pypa.io|pipenv]] – packaging and development workflow
* [[https://python-poetry.org/|poetry]] – packaging and development tool, pretty similar to pipenv but faster dependency resolution
* Docker
==== Articles ====
* [[https://modelpredict.com/python-dependency-management-tools|Overview of python dependency management tools]]
===== Shebang =====
Has to be on the first line of every executable script so the interpreter can be found. Correct Shebang for Python 3 is:
#!/usr/bin/env python3
===== Types =====
* [[http://mypy-lang.org/|mypy]] is an optional type checker for Python
* [[https://beepb00p.xyz/mypy-error-handling.html|Python: better typed than you think]] – mypy assisted error handling, exception mechanisms in other languages, fun with pattern matching and type variance (Dima Gerasimov, 2019)
* [[https://dropbox.tech/application/our-journey-to-type-checking-4-million-lines-of-python|Our journey to type checking 4 million lines of Python]] (Dropbox, 2019)
* [[http://calpaterson.com/mypy-hints.html|Applying mypy to real world projects]] – Some hints and tips for getting started with Mypy and introducing it to existing projects (Cal Paterson, 2020)
===== Libraries =====
* [[https://requests.readthedocs.io|requests]] – "HTTP for humans" – HTTP connections and data retrieval
* [[https://pymoo.org/|PyMoo]] – single- and multi-objective algorithms and features related to multi-objective optimization such as visualization and decision making.
* [[https://github.com/scrapy/scrapy|Scrapy]] – fast high-level web crawling & scraping framework
* [[https://altair-viz.github.io/|Altair]] – declarative visualisation.
===== web frameworks =====
* [[https://palletsprojects.com/p/flask/|Flask]]
* [[https://www.djangoproject.com/|Django]]
===== dos and don'ts =====
==== what you should NOT do with Python ====
* [[https://glyph.twistedmatrix.com/2020/08/never-run-python-in-your-downloads-folder.html|run Python in your downloads folder]]
===== cool projects made with Python =====
* [[https://github.com/ytdl-org/youtube-dl|youtube-dl]] – download videos from portals like youtube, vimeo, bitchute and [[http://ytdl-org.github.io/youtube-dl/supportedsites.html|lots of others]]
* can also be paired well with the mpv video player (not written in Python)
* [[https://github.com/kal39/ptmv|Py Terminal Media Viewer]] – utf-8/truecolor image and video viewer for the terminal
* [[https://www.home-assistant.io/|Home Assistant]] – home automation
* [[https://github.com/ansible/ansible|Ansible]] – DevOps
===== learning Python =====
* [[https://codecombat.com/|CodeCombat]] – Coding game where you can learn Python and [[.:js:|JS]] by programming the moves of an RPG character.
===== Troubleshooting =====
==== /usr/bin/env: 'python3\r': No such file or directory ====
Line endings are in Windows format (''CRLF'' / ''\r\n'') and not Linux/Unix format (''LF'' / ''\n''). Fix this with ''dos2unix'' or your text editor's save options.
==== error: option --single-version-externally-managed not recognized ====
''%%--single-version-externally-managed%%'' is an option used for Python packages instructing the ''setuptools'' module to create a Python package which can be easily managed by the host's package manager if needed.
=== Fedora / CentOS 7+: ===
dnf in python3-setuptools python3-wheel
=== others: ===
pip install -U setuptools wheel