undo "virtualenv . ". Have wrapper errors after "rmvirtualenv . "

257 views Asked by At

I have 'projects' directory in which I keep my virtual environments. But recently when I was creating a new one, I accidentally did this:

user1@laptop:~$ virtualenv .

making /home/user1 my new nameless virtual environment.

Then I think I ran "rmvirtualenv . " inside either /home/user1 or user1/bin directory, don't remember exactly, trying to remove it. I knew it would be a bad idea, but I backed everything up and did it anyway hoping to solve the issues I write about. The "rmvirtualenv . " didn`t work since when I call "user1@laptop:~$ source ./bin/activate," I still get: "(user1) user1@laptop:~$ "


Now when I 'source' my projects, let's say 'store' project, via "source ... virtualenvwrapper.sh" command, I see:

/home/user1/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/home/user1/bin/python and that PATH is set properly.

And then when activating it by "workon store", I get the error message below:

/home/user1/bin/python: No module named virtualenvwrapper

My .bashrc contains the following env variables:

export WORKON_HOME=$HOME/.virtualenvs

export PROJECT_HOME=$HOME/projects 

In /home/user1/bin, I have python* symlink and:
enter image description here Is there a way to get rid of these error messages? My projects work fine. All is good. Except for when I 'source' and then call 'workon', I get these wrapper errors. Maybe I have to point python* somewhere else? Don`t really know how this works... And how does one, in a safe way, undo "virtualenv . " command? I appreciate any suggestions. Thanks!

2

There are 2 answers

1
diametralpitch On

If your intention is to use virtualenv wrapper, you should be creating environments with mkvirtualenv instead of using virtualenv directly. It is a "wrapper" after all. The reason rmvirtualenv does not work in your case is because it was not created using mkvirtualenv (which would have created an environment in your WORKON_HOME directory). In order to remove an environment created with virtualenv (not the wrapper), you simply deactivate the environment and then delete its entire directory recursively. In your case, since you created it inside the home directory, you will have to sort through your files by looking at the time stamps and do your best to find and manually remove the corresponding files.

The errors you are seeing indicate that you are still using the new virtualenv you created in your home directory. You will need run the command 'deactivate' to exit from this environment and return to your system installed Python, where I am assuming you have virtualenv wrapper installed.

0
el347 On
cd /usr/local/bin
pip install virtualenvwrapper
source ~/.bashrc

No errors anymore. LOL.

To undo "virtualenv . ", I've deleted relevant files after sorting by timestamp, as kind people above recommended.