可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I created an environment with the following command: virtualenv venv --distribute
I cannot remove it with the following command: rmvirtualenv venv
-
This is part of virtualenvwrapper as mentioned in answer below for virtualenvwrapper
I do an ls
on my current directory and I still see venv
The only way I can remove it seems to be: sudo rm -rf venv
Note that the environment is not active. I'm running Ubuntu 11.10. Any ideas? I've tried rebooting my system to no avail.
回答1:
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.
回答2:
Just to echo what @skytreader had previously commented, rmvirtualenv
is a command provided by virtualenvwrapper
, not virtualenv
. Maybe you didn't have virtualenvwrapper
installed?
See VirtualEnvWrapper Command Reference for more details.
回答3:
Use rmvirtualenv
Remove an environment, in the $WORKON_HOME
.
Syntax:
rmvirtualenv ENVNAME
You must use deactivate before removing the current environment.
$ rmvirtualenv my_env
Reference: http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
回答4:
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/
回答5:
Simply remove the virtual environment from the system.There's no special command for it
rm -rf venv
回答6:
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
回答7:
I used pyenv uninstall my_virt_env_name
to delete the virual environment.
Note: I'm using pyenv-virtualenv installed through the install script.
回答8:
if you are windows user, then it's in C:\Users\your_user_name\Envs. You can delete it from there.
Also try in command prompt rmvirtualenv environment name.
I tried with command prompt so it said deleted but it was still existed. So i manually delete it.
回答9:
deactivate
is the command you are looking for. Like what has already been said, there is no command for deleting your virtual environment. Simply deactivate it!
回答10:
The following command works for me.
rm -rf /path/to/virtualenv
回答11:
so, I have done a bit of google, but none of the answers were satisfactory.
But accidentally , while scrolling through man pages of pip(utility to install python supported packages - virtualenv is one of them) , it was documented to use of "uninstall" keyword with pip, below is exact output straight from my terminal
indresh-VBX] **$ sudo pip uninstall virtualenv**
The directory '/home/indresh/.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.
Uninstalling virtualenv-15.1.0:
/usr/bin/virtualenv
/usr/local/bin/virtualenv
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/DESCRIPTION.rst
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/INSTALLER
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/METADATA
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/RECORD
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/WHEEL
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/entry_points.txt
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/metadata.json
/usr/local/lib/python2.7/dist-packages/virtualenv-15.1.0.dist-info/top_level.txt
/usr/local/lib/python2.7/dist-packages/virtualenv.py
/usr/local/lib/python2.7/dist-packages/virtualenv.pyc
/usr/local/lib/python2.7/dist-packages/virtuakmr.ndrsh@gmail.comlenv_support/__init__.py
/usr/local/lib/python2.7/dist-packages/virtualenv_support/__init__.pyc
/usr/local/lib/python2.7/dist-packages/virtualenv_support/argparse-1.4.0-py2.py3-none-any.whl
/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl
/usr/local/lib/python2.7/dist-packages/virtualenv_support/setuptools-28.8.0-py2.py3-none-any.whl
/usr/local/lib/python2.7/dist-packages/virtualenv_support/wheel-0.29.0-py2.py3-none-any.whl
Proceed (y/n)? y
Successfully uninstalled virtualenv-15.1.0
The directory '/home/indresh/.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.
--------------------------------