This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
Python is an interpreted, high-level, general-purpose programming language, first released in 1991. Python's design philosophy emphasizes code readability with its notable use of significant white space. Its language constructs and object oriented approach aim to help programmers write clear, logical code for small and large-scale projects.
Table of contents¶
Try to not use
$ pip install ... system wide. Prefer your system package manager instead
$ pip install ... is needed: then use it in a virtual environment (e.g. with
$ pip insall ... is needed outside a virtual environment: then use the
--user flag, in
order to not install system wide but only user wide! This is important because a system wide
installation could conflict with some packages.
pip without your package manager, i.e. never run
$ pip install --upgrade pip
$ python -m pip install --upgrade pip outside a virtual environment.
If you did updated
pip outside a virtual environment, then you can recover a working
$ sudo python -m pip uninstall pip, and then uninstall/re-install the
with your package manager (e.g.
$ sudo apt --reinstall install python-pip). See
How to compile explicitly¶
.pyccompiled files will land in
.pyccompiled files will land next to their
The major advantage with the last compilation method is that you can easily run the
How to package a Python program into a single file or folder with its dependencies¶
pyinstaller cheat sheet.
Python virtual environment (
venv) good practices¶
It's a good practice to have a dedicated
venv for a project needing python dependencies.
Create and enter a
pyenv lets you easily switch between multiple versions of Python:
See poetry cheat sheet.
Conda (with Miniconda)¶
See Conda cheat sheet.
If this cheat sheet has been useful to you, then please consider leaving a star here.