Skip to content

Python Virtual Environments: A Primer

realpython.com
3 pointsDerekBickerton1 comment
On HN

Comments

this whole notion of "activating" a venv really does cause more confusion and obfuscation than it solves. How?

Using it this way, without an "activate" step makes things plainer.

    python3.11 -m venv .venv/
    .venv/bin/python3 -m pip install --requirement etc/pip/requirement.txt
    .venv/bin/python3 -m pip freeze > etc/pip/requirement3.11.txt

    export PYTHONPATH=$(pwd)/src/python
    venv/bin/python3 -m mycorp.myapp.main

This notation can then be used in wrapper scripts in the project. Encouraging people to experiment in the shell without simultaneously and immediately making them reusable in scripts may lead to a "works-on-my-computer" attitude.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.