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

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

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

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

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


当前回答

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

$ pyenv virtualenv-delete <name>

其他回答

您可以按照以下步骤删除与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}

使用rmvirtualenv

删除一个环境,在$WORKON_HOME中。

语法:

rmvirtualenv ENVNAME

在删除当前环境之前,必须使用deactivate。

$ rmvirtualenv my_env

参考:http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html

我使用pyenv uninstall my_virt_env_name删除虚拟环境。

注意:我正在使用通过安装脚本安装的pyenv-virtualenv。

步骤1:删除virtualenv virtualenvwrapper,复制粘贴如下命令:

$ sudo pip uninstall virtualenv virtualenvwrapper

第二步:进入。bashrc目录,删除所有virtualenv和virtualenvwrapper

打开终端:

$ sudo nano .bashrc

向下滚动,你会看到下面的代码,然后删除它。

# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh

接下来,源.bashrc:

$ source ~/.bashrc

最后一步:没有终端/shell到/home找到。virtualenv(我忘记名字了,所以如果你发现类似于。virtualenv或。venv就删除它。这是可行的。

只需使用蟒蛇领航员删除选定的环境。