Virtual Environments & the '-m' Flag #2679
Replies: 1 comment 1 reply
-
Glad you're enjoying your BeeWare experience :-)
It is entirely a compartmentalisation thing, and isn't Windows-specific at all. Do things get out of hand? Yes. Very quickly, and very easily. Imagine you're working on two projects. One project requires setuptools < 58; one requires setuptools > 66. You literally can't resolve this in a single "monolithic" Python environment. Imagine the same thing, but the dependency causing a conflict isn't a library you're installing directly, but 5 dependencies deep in a chain. Same problem... now try to diagnose and fix it. Or, even if you're only working on one project: You're not quite sure how you're going to implement some new feature, so you install a library off PyPI. Which installs 3 other libraries. Which install 3 other libraries. Then you realise the original library doesn't do what you want. Now get yourself back to a clean state. In both cases, having a virtual environment is invaluable. Need 2 different versions of a library? Use 2 different virtual environments. Need to walk back an install? Delete the virtual environment and re-create it. Neither of these options are easy if you've got a single monolithic Python install. Is it possible to use Python without virtual environments? Sure. It's also possible to cut your hair while standing up in a hammock. But there are much easier (and safer) ways to do it :-)
Yes - it's mostly for the benefit of more complex scripts. When all you've got is a single file, However, |
Beta Was this translation helpful? Give feedback.
-
Hi all,
Just discovered BeeWare and I think I'm in love. Greetings and salutations to the community.
I do, however, have a couple of questions arising from the first few pages of the Toga Tutorial in the docs.
I see this a lot where it's recommended that Python libraries are installed and used in virtual environments. Why is this so highly recommended? I get the whole compartmentalization thing, but do things really get out of hand if we don't use venv? And if so, how do they get out of hand? Or is this just an MS Windows thing?
The docs also say that BeeWare scripts should be run thusly:
python -m helloworld
But I tried it both ways (
python hellowworld.py
) and it seems the same to me. Or are the differences only apparent in larger, more complex, scripts?Beta Was this translation helpful? Give feedback.
All reactions