What is the requirement of virtual environment in python however we have the playgrounds of python.?
When and why virtual environments is use?
Please answer with empirically experience.
Thank you
What is the requirement of virtual environment in python however we have the playgrounds of python.?
When and why virtual environments is use?
Please answer with empirically experience.
Thank you
venvs are essential (unless you’re happy installing everything into the main parent or system Python, breaking stuff if on Linux, or otherwise managing dependency hell yourself).
Typically you make a venv on the command line or in CI/CD pipelines.
You install what you want in a venv, can easily make a new one, and are free to delete it whenever you want, and there are even tools that will ship an app from a venv.
Playgrounds are kind of similar, except they run in a browser tab (where there is no system Python to worry about breaking), exporting them or downloading them is non-trivial (assuming it’s possible at all) and the website controls what gets installed in them, not you the user. They make it easy to share code examples with others online (although not necessarily easy to run that code example in the sharees chosen environment), and that very lack of control does make them a much more reproducible environment of sorts (depending on the website still being up when needed, and never changing it).
I’m guessing English isn’t your first language, so just so you know, directives like this read impolitely, as if you are assigning a task rather than asking for information from volunteers.
If I’m trying to constrain what sorts of answers I get back for a question, I would say something like “I’m more interested in the difference in how people use these than the technical differences between them.”
They said “please”, that’s good enough for me.
I just ignored the rest, and answered dogmatically, instead of empirically ![]()
If I’m not wrong, I have to entirely manage the dependencies and other stuff if I code in the main system Python
As Chris mentioned, English is not my first language, which is indeed correct. I sincerely apologize for any misunderstanding caused by my phrasing. ![]()
I have to entirely manage the dependencies and other stuff if I code in the main system Python
Kind of, but not directly. If you’re on a Linux distro with a main system Python, let the operating system handle that for you.
Otherwise, if you break some dependency installed in it, that your OS needs, it’s on you.
Not breaking the main Python environment, is the raison-d’etre of coding in a venv instead (or some other separate Python).
uv makes installing other Pythons and creating venvs very easy