我使用以下命令创建了一个环境:virtualenv venv——distribute

使用以下命令无法删除:rmvirtualenv venv - 这是virtualenvwrapper的一部分,如下面的virtualenvwrapper的答案所述

我在我的当前目录中做了一个l_1,我仍然看到venv

我可以删除它的唯一方法似乎是:sudo rm -rf venv

注意,环境不是活动的。我运行的是Ubuntu 11.10。什么好主意吗?我试过重启系统,但没有成功。


当前回答

如果你正在使用pyenv,可以删除你的虚拟环境:

$ pyenv virtualenv-delete <name>

其他回答

将虚拟环境从系统中删除:

rm -rf venv

(没有特别的命令)

您可以按照以下步骤删除与virtualenv相关的所有文件,然后重新安装virtualenv并使用它

cd {python virtualenv folder}

find {broken virtualenv}/ -type l                             ## to list out all the links

deactivate                                           ## deactivate if virtualenv is active

find {broken virtualenv}/ -type l -delete                    ## to delete the broken links

virtualenv {broken virtualenv} --python=python3           ## recreate links to OS's python

workon {broken virtualenv}                       ## activate & workon the fixed virtualenv

pip3 install  ... {other packages required for the project}

下面的命令对我有用。

rm -rf /path/to/virtualenv

您可以通过递归地卸载所有依赖项,然后删除venv来删除所有依赖项。

编辑包括艾萨克特纳评论

source venv/bin/activate
pip freeze > requirements.txt
pip uninstall -r requirements.txt -y
deactivate
rm -r venv/

Deactivate是您正在寻找的命令。如前所述,没有删除虚拟环境的命令。简单地禁用它!