DEV Community

Cover image for How do you organize your virtual environments?

How do you organize your virtual environments?

Leonardo Furtado on October 20, 2019

I am currently programming in Python at home and for each project I have a virtual environment, this practice avoid a lot of problems. A while ago ...
Collapse
 
zeljkobekcic profile image
TheRealZeljko • • Edited

Either use pipenv or poetry

I first used pipenv and it feels good(?). But there are some dependency problems which are stated on the page of poetry. That is why I am trying poertry for another project while using pipenv in other projects.

I can't understand how it is possible for a community that large to have:

  • pip + virtualenv but no fully reproducible enviroments and no dependency management
  • pipenv well, sometimes it is slow as f$?# and the dependency management is not the bes
  • poetry I don't know that much it to point out any negative aspects of it.

But yeah, I use pipenv regularly (for about half a year now) and am pretty fine with it. But still using poetry for the newest project to see how it works and if I like it more.

The only downside is to poetry is that PyCharm has no support for poetry. You need to set it up as a standard virtual environment in PyCharm, but that is not a real problem. You just have to know about that.

If someone has another tool I should give a shot which is actively in development and near feature complete I would give it a try.

//edited: Grammar, Spelling, Syntax of one or the other sentence; there might be more

Collapse
 
furtleo profile image
Leonardo Furtado •

I never used poetry, I'll try to use in some projects later, thanks for the comment <3

Collapse
 
orenovadia profile image
orenovadia • • Edited

If you insist on using pip + virtualenv I think that virtualenvwrapper is a must.

It basically keeps all your venv's in one place and helps you switch between with autocompletion.

PS: pip + virtualenv is not avoidable in most cases: most open source libraries use it, and I am not sure that pipenv is suitable for libraries (and not just for top level applications)

Collapse
 
furtleo profile image
Leonardo Furtado •

I really like pip + virtualenv, I think virtualenvwrapper will be a usefull tool to me. Thanks for the comment!

Collapse
 
davidmm1707 profile image
David MM๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป •

pipenv environment at the root level of each project

I don't know if this is the proper way or not, so if anyone knows a better way, feel free to give me (us) tips.

Collapse
 
furtleo profile image
Leonardo Furtado •

I used it like that too, but sometimes I did git add. and sent my environment to Github by mistake.

Collapse
 
davidmm1707 profile image
David MM๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป •

That's why .gitignore exists ๐Ÿ˜€

Thread Thread
 
furtleo profile image
Leonardo Furtado •

It is ok to add the virtual environment in gitignore to personal projects, but what if the project is from another user? :/

Thread Thread
 
nicolaerario profile image
Nicola Erario •

You can set your local โ€œglobal.gitignoreโ€.

Thread Thread
 
furtleo profile image
Leonardo Furtado •

wow, I'll see it, thanks <3

Collapse
 
thefern profile image
Fernando B ๐Ÿš€ •

I don't know if there is 100% correct way. For me it makes sense to keep an environment for projects alike as long as they are using same pip packages. One env per project seems like a good way to go too, if you have specific (pip packages or python) versions tied to a project.

In your case if all your environments are exactly the same (pip packages and python version) it would seem like an overkill to me.

Collapse
 
furtleo profile image
Leonardo Furtado •

Some projects use version 2.7 only. Besides having projects where I use different versions of some libraries ...