问题:如何删除/删除virtualenv?

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

:我无法用下面的命令将其删除rmvirtualenv venv这是部分virtualenvwrapper中提到下面virtualenvwrapper答案

ls在当前目录上执行了,但仍然看到venv

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

请注意该环境处于非活动状态。我正在运行Ubuntu 11.10。有任何想法吗?我尝试重新启动系统无济于事。

I created an environment with the following command: virtualenv venv --distribute

I cannot remove it with the following command: rmvirtualenv venvThis is part of virtualenvwrapper as mentioned in answer below for virtualenvwrapper

I do an lson 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.


回答 0

而已!没有用于删除虚拟环境的命令。只需停用它,然后通过递归删除它即可消除应用程序的工件。

请注意,无论您使用哪种虚拟环境,都一样。virtualenvvenv,Python环境pyenvpipenv都在这里基于同样的原则。

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.


回答 1

只是为了回应@skytreader先前评论的内容,它rmvirtualenv是由virtualenvwrapper而不是提供的命令virtualenv。也许您没有virtualenvwrapper安装?

有关更多详细信息,请参见VirtualEnvWrapper命令参考

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.


回答 2

采用 rmvirtualenv

在中删除环境$WORKON_HOME

句法:

rmvirtualenv ENVNAME

在删除当前环境之前,必须使用停用功能。

$ rmvirtualenv my_env

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

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


回答 3

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

编辑,包括艾萨克·特纳评论

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

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/

回答 4

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

rm -rf venv

Simply remove the virtual environment from the system.There’s no special command for it

rm -rf venv

回答 5

来自virtualenv的官方文档https://virtualenv.pypa.io/en/stable/userguide/

删除环境

只需删除虚拟环境,然后将其所有内容删除即可,只需删除虚拟环境即可:

(ENV)$ deactivate
$ rm -r /path/to/ENV

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

回答 6

如果您使用的是pyenv,则可以删除您的虚拟环境:

$ pyenv virtualenv-delete <name>

If you are using pyenv, it is possible to delete your virtual environment:

$ pyenv virtualenv-delete <name>

回答 7

以下命令对我有用。

rm -rf /path/to/virtualenv

The following command works for me.

rm -rf /path/to/virtualenv

回答 8

我曾经pyenv uninstall my_virt_env_name删除虚拟环境。

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

I used pyenv uninstall my_virt_env_name to delete the virual environment.

Note: I’m using pyenv-virtualenv installed through the install script.


回答 9

如果您是Windows用户并且正在使用conda在Anaconda提示符下管理环境,则可以执行以下操作:

确保停用虚拟环境或重新启动Anaconda Prompt。使用以下命令删除虚拟环境:

$ conda env remove --name $MyEnvironmentName

或者,您可以转到

C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\envs\MYENVIRONMENTNAME

(这是默认文件路径)并手动删除文件夹。

If you are a Windows user and you are using conda to manage the environment in Anaconda prompt, you can do the following:

Make sure you deactivate the virtual environment or restart Anaconda Prompt. Use the following command to remove virtual environment:

$ conda env remove --name $MyEnvironmentName

Alternatively, you can go to the

C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\envs\MYENVIRONMENTNAME

(that’s the default file path) and delete the folder manually.


回答 10

如果您是Windows用户,则位于C:\ Users \您的用户名\ Envs中。您可以从那里删除它。

也可以在命令提示符下输入rmvirtualenv环境名称。

我尝试使用命令提示符,所以它说已删除,但它仍然存在。所以我手动将其删除。

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.


回答 11

deactivate是您要查找的命令。就像已经说过的一样,没有删除虚拟环境的命令。只需停用它!

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!


回答 12

如果您是Windows用户,还可以通过以下步骤删除环境:C:/Users/username/Anaconda3/envs 在这里,您可以看到虚拟环境列表,并删除不再需要的环境。

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.


回答 13

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

You can follow these steps to remove all the files associated with virtualenv and then reinstall the virtualenv again and using it

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}


回答 14

步骤1:通过复制并粘贴以下命令来删除virtualenv virtualenvwrapper:

$ sudo pip uninstall virtualenv virtualenvwrapper

步骤2:转到.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

最后步骤:在没有终端/外壳的情况下,转到/ home并查找.virtualenv(我忘记了名称,因此,如果您发现与之相似.virtualenv.venv只是删除它。这将起作用。

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.


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。