I created an environment with the following command: virtualenv venv --distribute
I cannot remove it with the following command: rmvirtualenv venv
That's it! 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. virtualenv
, venv
, Anaconda environment, pyenv
, pipenv
are all based the same principle here.
step 1: delete virtualenv virtualenvwrapper by copy and paste the following command below:
$ sudo pip uninstall virtualenv virtualenvwrapper
step 2: go to .bashrc and delete all virtualenv and virtualenvwrapper
open terminal:
$ sudo nano .bashrc
scroll down and you will see the code bellow then delete it.
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
next, source the .bashrc:
$ source ~/.bashrc
FINAL steps: without terminal/shell go to /home and find .virtualenv
(I forgot the name so if your find similar to .virtualenv
or .venv
just delete it. That will work.
If you're a windows user, you can also delete the environment by going to: C:/Users/username/Anaconda3/envs
Here you can see a list of virtual environment and delete the one that you no longer need.
There is no command to remove a virtualenv so you need to do that by hand, you will need to deactivate
if you have it on and remove the folder:
deactivate
rm -rf <env name>
When you create an environment the python uses the current version by default, so if you want another one you will need to specify at the moment you are creating it. To make and env. with Python 3.7 called MyEnv
just type:
python3.7 -m venv MyEnv
Now to make with Python 2.X use virtualenv
instead of venv
:
python2.7 -m virtualenv MyEnv
If any of the previous lines of code didn't worked you probably don't have the specific version installed. First list all your versions with:
ls -ls /usr/bin/python*
If you didn't find it, install Python 3.7 using apt-get
:
sudo apt-get install python3.7
And with yum
:
sudo yum install python3
pip install --upgrade pip
You can remove all the dependencies by recursively uninstalling all of them and then delete the venv.
Edit including Isaac Turner commentary
source venv/bin/activate
pip freeze > requirements.txt
pip uninstall -r requirements.txt -y
deactivate
rm -r venv/
from virtualenv's official document https://virtualenv.pypa.io/en/stable/userguide/
Removing an Environment
Removing a virtual environment is simply done by deactivating it and deleting the environment folder with all its contents:
(ENV)$ deactivate $ rm -r /path/to/ENV