I am new to python development using virtualenv. I have installed python 2.7, pip, virtualenv, virtualenvwrapper in windows and I am using windows PS. I have referred lots of tutorials for setting this up. Most of them contained the same steps and almost all of them stopped short of explaining what to do after the virtualenv was created.
How do I actually work in a virtualenv? suppose I want to create a new flask application after installing that package in my new env virtualenv (eg; testenv).
If I already have an existing project and I want to put it inside a newly created virtual env, how do I do that? How should the folder structure be like?
My understanding of virtual env is that it provides a sandbox for your application by isolating it and keeping all its dependencies to itself in that particular env (and not sharing and it with others). Have I understood it wrong?
Please help me clear this.
You open up Command Prompt and activate the virtualenv:
When you run
python
andpip
, they run in the virtualenv. You have to do this for every Command Prompt window, since working in a virtualenv is really just runningC:\path\to\env\bin\python
instead of justpython
andC:\path\to\env\bin\pip
instead ofpip
.It doesn't matter. When you install Python packages, they get installed globally into
C:\Python27\site-packages
. With virtualenv, you can create isolated Python environments that have their own packages, so if you're working on two projects that require different versions of a package, they can coexist without any issues.Some people make a folder for their virtualenvs (like
C:\Users\you\Virtualenvs\my_website
). You can also store it with your project (likeC:\Users\you\Projects\my_website\venv
). Once you activate it, the location doesn't matter. I use the latter.Nope. The only point that I would clarify is that the "sandbox" is only for Python's packages, it doesn't affect your application in any way.