Discussion about this post

User's avatar
James E. A.'s avatar

In section 5, you might want to emphasize a bit more that exactly “python -m” should be used, with “python” per se as the base command—rather than the “py -3.8” or “python3.8” or whatever exact command it was that you (if *and only if* your faded memory from _n_ weeks ago is exactly correct) created the venv with in the first place.

I suppose this doesn’t affect anything if you only have runtimes from the exact source you recommend in your article, but it is necessary to keep you safe and healthy in any edge cases where you (whether accidentally or knowingly) have Python runtimes from different sources installed on the same machine—e.g. a Python.org-sourced one, plus a company internal one; or if you're on Linux and happen to *have* a personally patched CPython of the same version as the system one, which you use for only some of your projects. Or even if you had to use the Windows-Store provided runtime, for some reason—that would prevent any problems from occurring once the venv exists!

Expand full comment
Argumentarium's avatar

If you want to “Always use pip in a virtual environment” maybe its a good idea to alias pip like

alias pip=pip --require-virtualenv

To allow pip to only run in a virtual environment; exit with an error otherwise.

Expand full comment
25 more comments...

No posts