What can happen to my project if I remove the virtual environment configured for it?

2

Let's say I created a virtual environment through virtualenvwrapper $ mkvirtualenv venv . I create my project, make the necessary settings, start working on the project and one day I remove the virtual environment $ rmvirtualenv venv .

What are the effects that could happen in my project?

    
asked by anonymous 19.09.2015 / 17:53

1 answer

0

The idea of a virtual environment is precisely to provide an environment for your project, no matter how redundant it may seem. That is, as long as you know how to set up an environment for your project, it does so if you delete the environment in which you are working. In fact, you can even recreate this environment on another machine (for example on a remote server) that your project will work.

However, keeping all of your project's (and possibly many others') settings in your head is somewhat of a problem. You can forget about some specific dependency and face enough difficulty to recreate your environment. For this, it is common to save together with your project a list of the packages on which it depends. You can create this list using pip:

pip freeze > dependencias.txt

If you take a look at the generated file, you'll see that, in addition to the package names, their versions are also included. Because of this, it is strongly recommended that you include this file in your version control system.

So if you accidentally delete your virtual environment, or need to run your project on another machine, you just have to install the packages in that list. Again, the pip has a command for this. After creating and activating a new virtual environment, run:

pip install -r dependencias.txt

And right, your project should work properly.

    
20.09.2015 / 19:01