如何删除/删除virtualenv?

本文翻译自:How do I remove/delete a virtualenv?

I created an environment with the following command: virtualenv venv --distribute 我使用以下命令创建了一个环境: 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 我无法使用以下命令将其删除: rmvirtualenv venv 这是virtualenvwrapper的一部分,如下rmvirtualenv venv virtualenvwrapper的 回答中所述

I do an ls on my current directory and I still see venv 我在当前目录上执行了ls ,但仍然看到venv

The only way I can remove it seems to be: sudo rm -rf venv 我可以删除它的唯一方法似乎是: sudo rm -rf venv

Note that the environment is not active. 请注意,该环境处于非活动状态。 I'm running Ubuntu 11.10. 我正在运行Ubuntu 11.10。 Any ideas? 有任何想法吗? I've tried rebooting my system to no avail. 我尝试重新启动系统无济于事。


#1楼

参考:https://stackoom.com/question/kB1N/如何删除-删除virtualenv


#2楼

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. virtualenvvenv ,Anaconda环境, pyenvpipenv都基于相同的原理。


#3楼

Just to echo what @skytreader had previously commented, rmvirtualenv is a command provided by virtualenvwrapper , not virtualenv . 只是为了回应@skytreader先前的评论, rmvirtualenvvirtualenvwrapper提供的命令,而不是virtualenv Maybe you didn't have virtualenvwrapper installed? 也许您没有安装virtualenvwrapper

See VirtualEnvWrapper Command Reference for more details. 有关更多详细信息,请参见VirtualEnvWrapper命令参考 。


#4楼

You can remove all the dependencies by recursively uninstalling all of them and then delete the venv. 您可以通过递归卸载所有依赖项来删除所有依赖项,然后删除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楼

只需从系统中删除虚拟环境即可,无需特殊命令

rm -rf venv

#6楼

Use rmvirtualenv 使用rmvirtualenv

Remove an environment, in the $WORKON_HOME . $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 参考: http : //virtualenvwrapper.readthedocs.io/en/latest/command_ref.html

你可能感兴趣的:(python,virtualenv)