Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset virtualenv and pip?

I installed virtualenv on my Ubuntu 10.04 server.

Now when I do pip freeze it shows me the following packages:

Django==1.2.4
distribute==0.6.10
python-apt==0.7.94.2ubuntu6.2
virtualenv==1.5.1
wsgiref==0.1.2

When I do "pip uninstall Django" it says:

pip uninstall Django
Uninstalling Django:
Proceed (y/n)? y
Successfully uninstalled Django

Ideally this should uninstall Django but it doesn't. I can still see the same packages when I do "pip freeze".

Now bear with me, the other weird thing is that when I create a virtualenv and then do "pip freeze" inside it, I see only one package and that is "wsgiref" which is weird because it should ideally be blank.

Also, in spite of creating this virtualenv with --no-site-packages I can still create a new django project with "django-admin.py startproject".

When I start python interpreter inside this virtualenv and do "import django" it gives me the error "No module named django".

Also when I try to install "pip install Django" inside the virtualenv it asks for sudo permissions which shouldn't happen ideally.

How do I sort out this mess. Any way to just reset everything pep and virtualenv?

like image 835
Sushi Avatar asked Feb 06 '11 13:02

Sushi


People also ask

How do I delete a virtual environment in pip?

There is no command for deleting your virtual environment. Simply deactivate it and rid your application of its artifacts by recursively removing it. Note that this is the same regardless of what kind of virtual environment you are using.

How do I enable pip virtual env?

To create a virtual environment, go to your project's directory and run venv. If you are using Python 2, replace venv with virtualenv in the below commands. The second argument is the location to create the virtual environment. Generally, you can just create this in your project and call it env .

How do I get out of Python virtualenv?

You can exit from the virtualenv using exit command, or by pressing Ctrl+d.


2 Answers

As far as I can tell, the only purpose of a venv is to manage dependencies.

You should be safe to just deactivate the venv, delete it, and create a new one using virtualenv venv; source venv/bin/activate.

This will give you a fresh start.

like image 56
Brad Johnson Avatar answered Oct 07 '22 01:10

Brad Johnson


Best way to reset the virtual environment

Windows environment use the below command:

pip freeze > unins && pip uninstall -y -r unins && del unins

Linux environemnt use the below command:

pip freeze > unins && pip uninstall -y -r unins && rm unins
like image 30
Sathia Avatar answered Oct 07 '22 00:10

Sathia