![rw-book-cover](https://substackcdn.com/image/fetch/w_1200,h_600,c_limit,f_jpg,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25d69b07-ab18-4723-b34a-4e7502ec39f9_1024x1024.png) --- > *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](https://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* - [View Highlight](https://read.readwise.io/read/01hkpy3r62aayceghyxxscbtn6) --- > 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. - [View Highlight](https://read.readwise.io/read/01hkpy7wthad66spwcyq6z0kbj) --- > 2. 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. --- > 3. 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. - [View Highlight](https://read.readwise.io/read/01hkpyb2qe5kpn1stjd5wtnay2) --- > 4. 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. --- > 5. To create a virtual environment, use “venv” and only “venv” - [View Highlight](https://read.readwise.io/read/01hkpyh2x22jzv67wz8wav4231) --- > “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. - [View Highlight](https://read.readwise.io/read/01hkpyh9rdcf7nzadsk430g0w4) --- > 6. 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. - [View Highlight](https://read.readwise.io/read/01hkpyja7mxy7k3hdpqs6xkenv) ---