logoalt Hacker News

zahlmanlast Tuesday at 5:02 PM1 replyview on HN

> But the nice part is that both of those work, and you can pick whichever one you prefer.

Yep. And so does the pyenv approach (which I understand involves permanently adding a relative path to $PATH, wherein the system might place a stub executable that invokes the venv associated with the current working directory).

And so do hand-made subshell-based approaches, etc. etc.

In "development mode" I use my activation-script-based wrappers. When just hacking around I generally just give the path to the venv's python explicitly.


Replies

kstrauserlast Tuesday at 5:30 PM

I use your "hacking around" method for things like cron jobs, with command lines like:

  * * * * * /path/to/project/.venv/python /path/to/project/foo.py
It's more typing one time, but avoids a whole lot of fragility later.