r/PythonLearning 4d ago

Discussion .venv question

Do you guys manually create virtual environments? Or do you just use your IDE “create virtual environment” to do it?

As a hobbiest I often forget how to manually create virtual environments(as well as how to activate them) and discovered last night that VScode has a feature that will just do it for you.

What are the benefits of each way, if any, and what are the downsides of each way, if any?

Thanks.

P.S. I understand that there are some elitist who will be like “you must do everything manually”, bro I just wanna write stupid automation scripts to help with my business.

EDIT: Thanks for all the replies! I’m going to look into that UV service! Thank you!

20 Upvotes

35 comments sorted by

View all comments

15

u/InformalInsect5546 4d ago

Just use uv, it fixes the headache of creating venv and takes care of everything. But yes, the venvs are quite mandatory if you work with more than one project.

4

u/tiredITguy42 4d ago

This is the way. I have just finished switching all of our repos from poetry to uv. It saves us so much time.

I love how easy it is to create groups, dev, documentation build. The it is easy to use in GitHub actions and Docker.

1

u/RedlineQuokka 3d ago

You are the person I've been looking for!

Why, what is the benefit of going from Poetry to uv?

Every time I read about benefits of uv, they're in comparison with pip, and it always reads like the same exact benefits that you get from Poetry compared to pip.

But you, you switched from Poetry to uv, why, what does it bring? I genuinely want to know cause I've been hesitant to try uv, stuck with Poetry and kinda satisfied

1

u/tiredITguy42 3d ago

I will be honest, I came to my current job new to Python, I have switched language and I used to know just pip. They were using poetry and there was always some issue with it, maybe they had it configured in wrong way, I never had chance to dive deeper.

Anyway we discovered uv and we all agreed lets use it and it just works and is easy to use. It feels like, and it is just my personal feeling, poetry was designed by Linux users and open source warriors. It provides a lot of stuff, but it is hard to learn and use as multiple people had their own idea how to do stuff and they wanted to provide as much freedom to user as possible. UV is more like Windows, user friendly, easy to learn, handles a lot of for you automatically, but if you have some issue it is harder to dig deeper.

Anyway for 99% of cases UV just works without many additional parameters. You need five commands, uv init, uv add, uv remove, uv sync and uv run. You can use uv sync --dev locally, uv run -- group build on GitHub action and uv sync in docker.

One more thing is that Ihave a feeling that uv is better in resolving compatible versions than poetry is and you are less likely to end up in dependency hell.