Uninstall virtualenv which was installed through sudo pip

45,833

Solution 1

I was looking for the same thing and I saw this by chance. you can do this.

sudo apt-get remove virtualenv  
sudo apt-get remove --auto-remove virtualenv 

If it is normal, the following statement is not executed. But try it once.

sudo apt-get purge python-virtualenv  
sudo apt-get purge --auto-remove python-virtualenv

Solution 2

try sudo pip uninstall virtualenv and this should work

Share:
45,833

Related videos on Youtube

shaun
Author by

shaun

Graduate student in Computer Science.

Updated on September 18, 2022

Comments

  • shaun
    shaun over 1 year

    ***********Update2******************

    Tried and successfully created a virtual environment using virtualenv.

    [08:05 USER@system ~] > mkdir test_virtual
    [08:05 USER@system ~] > virtualenv test_virtual/
    New python executable in /home/USER/test_virtual/bin/python
    Installing setuptools, pip, wheel...done.
    [08:05 USER@system ~] > ls test_virtual/
    bin  include  lib  local  pip-selfcheck.json
    

    ***********Update1******************

    As requested here are the pastebin links to pip list and pip3 list.

    ***********Original******************

    I installed virtualenv using sudo pip install virtualenv, which after reading on several answers here is actually not a good practice. When I try to uninstall it (mainly because I'm planning to go the anaconda way and I don't like extra dirt that I don't use on my system) I get the following error:

    (09:20 USER@system ~) > sudo pip uninstall virtualenv
    The directory '/home/USER/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled.
    Please check the permissions and owner of that directory.
    If executing pip with sudo, you may want sudo's -H flag.
    Cannot uninstall requirement virtualenv, not installed
    The directory '/home/USER/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled.
    Please check the permissions and owner of that directory.
    If executing pip with sudo, you may want sudo's -H flag.
    

    When I use sudo -H flag, I get this:

    Cannot uninstall requirement virtualenv, not installed
    

    But I confirmed that virtualenv is still installed:

    (09:25 USER@system ~) > which virtualenv
    virtualenv is /usr/local/bin/virtualenv
    virtualenv is /usr/local/bin/virtualenv
    virtualenv is /usr/local/bin/virtualenv
    virtualenv is /usr/local/bin/virtualenv
    

    How do I uninstall virtualenv from my system?

    Thanks.

    • shaun
      shaun almost 8 years
      I've removed them.
    • edwinksl
      edwinksl almost 8 years
      Are you sure you installed virtualenv using sudo pip install virtualenv instead of sudo pip3 install virtualenv? Can you do sudo pip list and sudo pip3 list?
    • shaun
      shaun almost 8 years
      I did those commands. They spit out a bunch of package names and at the end of the list the same error that says "the directory /home/USER/.cache/pip/http or its parent directory..." was also displayed for both pip and pip3. Also when I grep'd the list for virtualenv (using both virtual as the pattern and env as a the pattern) I didn't get any output except the error.
    • edwinksl
      edwinksl almost 8 years
      Can you put those outputs into your question or put them into a pastebin and link the pastebin? We are going to need more information than what you have given so far to figure out what happened.
    • edwinksl
      edwinksl almost 8 years
      Hmm, so pip list and pip3 list don't have virtualenv, which is at least consistent with the "Cannot uninstall requirement virtualenv, not installed" error message. If you just try to run virtualenv, are you able to create virtual environments?
    • shaun
      shaun almost 8 years
      Yes. I've updated my question with the results.
    • user2018197
      user2018197 about 7 years
      @shaun How did you solve this? I too have installed virtualenv pip install virtualenv and now I cannot remove it. Also virtualenv does not show up in pip freeze or pip list. How did you uninstall virtualenv?