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:
Top comments (12)
Either use
pipenv
orpoetry
I first used
pipenv
and it feels good(?). But there are some dependency problems which are stated on the page ofpoetry
. That is why I am tryingpoertry
for another project while usingpipenv
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 managementpipenv
well, sometimes it is slow as f$?# and the dependency management is not the bespoetry
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 usingpoetry
for the newest project to see how it works and if I like it more.The only downside is to
poetry
is thatPyCharm
has no support forpoetry
. You need to set it up as a standard virtual environment inPyCharm
, 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
I never used poetry, I'll try to use in some projects later, thanks for the comment <3
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 thatpipenv
is suitable for libraries (and not just for top level applications)I really like
pip
+virtualenv
, I think virtualenvwrapper will be a usefull tool to me. Thanks for the comment!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.
I used it like that too, but sometimes I did git add. and sent my environment to Github by mistake.
That's why .gitignore exists 😀
It is ok to add the virtual environment in gitignore to personal projects, but what if the project is from another user? :/
You can set your local “global.gitignore”.
wow, I'll see it, thanks <3
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.
Some projects use version 2.7 only. Besides having projects where I use different versions of some libraries ...