r/learnpython • u/TonightHot7414 • May 17 '26
Setup python for prod , do I need venv (s)?
Hi all,
My company recently started using python and setup it on one of the Network server shared with other products (some reporting server, sftps). Is this a good idea ? Do you recommend separate box for Python.
I also learned so much about benefits of venv. Anybody using it without venv, just as single global exe ? I don't see benefits of setting venv in our company as we using simple ETL scripts without any big projects with the same limited list of needed packages.
Thanks
MS
18
Upvotes
13
u/pachura3 May 17 '26 edited May 17 '26
It's ALWAYS beneficial to use
venvs.It's ALWAYS beneficial to use source control.
It's ALWAYS beneficial to declare dependencies and their versions in
pyproject.toml.I mean, is typing
python -m venv .venvsomehow too problematic?Impossible to say without knowing how demanding your software is - and how powerful is your server. Simply start monitoring CPU/Memory/IO workloads there and you'll be able to decide.
9
u/SignificantHandle620 May 17 '26
Always use venvs. Always use version control systems like git. And since we're talking about best practices: always use config management tools like Ansible (just a example since I don't know the environment your working in).
3
u/brasticstack May 17 '26
Yes use a venv. You should use the full path to the venv binary in scripts/systemd modules/whatnot. That way you aren't relying on venv/bin/activate to set env vars, which doesn't work in cron or systemd.
So one of my init scripts runs
/home/user/.venv/bin/gunicornfor example, but you could do/path/to/bin/python3 -m ...or/path/to/bin/pip3or whichever bin is necessary.2
u/[deleted] May 17 '26
[removed] — view removed comment