How to reset virtualenv and pip?

I installed virtualenv on my Ubuntu 10.04 server.

Now, when I do a hang, 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 remove Django, but it is not. I still see the same packages when I do "freeze".

Now carry me, another strange thing is that when I create virtualenv and then "lock" inside it, I see only one package, and this is "wsgiref", which is strange, because ideally it should be empty.

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

When I run the python interpreter inside this virtualenv and do "import django", it gives me the error "There is no module named django".

Also, when I try to install "pip install Django" inside virtualenv, it asks for sudo permissions which should not be ideal.

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

+7
source share
2 answers

As far as I can tell, the sole purpose of venv is dependency management.

You can safely deactivate venv, delete it, and create a new one using virtualenv venv; source venv/bin/activate virtualenv venv; source venv/bin/activate virtualenv venv; source venv/bin/activate virtualenv venv; source venv/bin/activate .

This will give you a fresh start.

0
source

This question is old, but it ended up on the first page, so it's hard to determine which versions of pip and virtualenv you are using.

There are several things we can do to fix this, though.

  1. Exit all virtualenv and check your $PYTHONPATH . Make sure it is empty; otherwise run unset PYTHONPATH .
  2. Create a fresh virtualenv in myenv using virtualenv --no-site-packages myenv .
  3. Activate myenv and check your $PYTHONPATH again. It should be just myenv .
  4. Run pip with an absolute path, e.g. myenv/bin/pip freeze .
  5. If pip not available inside your virtualenv, you may need to install it manually.

Related: virtualenv --no-site-packages and pip still find global packages?

Finally, run the Python shell using myenv/bin/python , then run

 >>> import sys >>> sys.path 

If pip can find wsgiref , then wsgiref should be in one of the paths in sys.path . Use this hint!

0
source

Source: https://habr.com/ru/post/1338629/


All Articles