Properties5

rw-book-cover


You can protect yourself against a lot of packaging pain by sticking to one recipe for installing and running Python:

  1. Don’t install the latest major version of Python
  2. Use only the python.org installer on Windows and Mac, or official repositories on Linux.
  3. Never install or run anything outside of a virtual environment
  4. Limit yourself to the basics: “pip” and “venv”
  5. If you run a command, use “-m”
  6. When creating a virtual environment, be explicit about which Python you use

Don’t install the latest major version of Python Yes, the latest version is shiny. It’s faster, has cool features, and smells good. I’m not saying you should not give it a try, and play with it. However, don’t use it in any project. So if Python 3.11 is the latest major version, at the maximum, use 3.10.


  1. A. On Windows and Mac, use the official installer … Should you use Homebrew, the Windows store, or use Anaconda? No. Go to python.org, and use their Python installer for Windows or their installer for Mac.
  2. B. On Linux, use the official repositories Use whatever official tool comes with your distribution to install Python, be it “apt”, “yum”, “dnf”, etc.

  1. To install things, use pip, and only pip Don’t use conda. Don’t use poetry, pipenv, pdm, easy_install Don’t use pipx. pipx is not pip. At all. Don’t use apt, yum, etc.

  1. Always use pip in a virtual environment … This rule is the most important one. If you need to install something, anything, you should do so in a virtual environment. Even to install black, jupyter, mypy or whatever you are thinking right now, do it in a virtual environment.

  1. To create a virtual environment, use “venv” and only “venv”

“venv” is a command that comes with most Python installations, and it’s the command you should use to create a new virtual environment. There are other commands such as “virtualenv” and “virtualenvwrapper”. Don’t use them.


  1. When running a Python command use “-m” “-m” is a flag on the “python” command that few users seem to know about. It lets you run any importable Python module, no matter where you are.