How do you organize your virtual environments?
Leonardo Furtado

Leonardo Furtado @furtleo

About: Currently learning more about Go, tests and devops.

Location:
Brazil
Joined:
Jun 22, 2019

How do you organize your virtual environments?

Publish Date: Oct 20 '19
13 12

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 I put virtual environments in their respective project directories, but that raised some issues with git and stuff...

So how do you organize your virtual environments? Is there a good practice for this?

me:
projects
├── archives
│   └── project1
├── lab
│   └── project2
├── study
│   └── project3
├── venvs
│   ├── project1venv
│   ├── project2venv
│   └── project3venv

In general, I organize my directories like @cecilelebleu, with just a few changes. See:

Comments 12 total

  • David MM👨🏻‍💻
    David MM👨🏻‍💻Oct 20, 2019

    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.

    • Leonardo Furtado
      Leonardo FurtadoOct 20, 2019

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

      • David MM👨🏻‍💻
        David MM👨🏻‍💻Oct 20, 2019

        That's why .gitignore exists 😀

        • Leonardo Furtado
          Leonardo FurtadoOct 20, 2019

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

  • TheRealZeljko
    TheRealZeljkoOct 20, 2019

    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

    • Leonardo Furtado
      Leonardo FurtadoOct 20, 2019

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

  • orenovadia
    orenovadiaOct 20, 2019

    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)

    • Leonardo Furtado
      Leonardo FurtadoOct 20, 2019

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

  • Fernando B 🚀
    Fernando B 🚀Oct 25, 2019

    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.

    • Leonardo Furtado
      Leonardo FurtadoOct 28, 2019

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

Add comment