Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing a conda environment with invalid name?

Tags:

conda

Using PyCharm I've created a project with a conda interpreter. Pycharm automatically creates a conda environment for it. Short after, I realized I wanted another location for the project. Thus I removed the project folder. Then I realized I want to delete the conda environment.

So first I verify that the environment is there.

(base) C:\Users\Ludvig>conda env list
WARNING: The conda.compat module is deprecated and will be removed in a future release.
WARNING: The conda.compat module is deprecated and will be removed in a future release.
# conda environments:
#
base                  *  C:\Users\Ludvig\Anaconda3
2019 Proteinanalys       C:\Users\Ludvig\Anaconda3\envs\2019 Proteinanalys

Then I try to remove it.

(base) C:\Users\Ludvig>conda env remove --name "2019 Proteinanalys"
WARNING: The conda.compat module is deprecated and will be removed in a future release.
WARNING: The conda.compat module is deprecated and will be removed in a future release.

CondaValueError: Invalid environment name: '2019 Proteinanalys'
  Characters not allowed: ('/', ' ', ':')

Any thoughts on how to delete this environment?

like image 236
LudvigH Avatar asked May 03 '19 09:05

LudvigH


2 Answers

Try specifying the path using the --prefix flag instead:

conda env remove --prefix "C:\Users\Ludvig\Anaconda3\envs\2019 Proteinanalys"

or, similarly,

conda remove --all --prefix "C:\Users\Ludvig\Anaconda3\envs\2019 Proteinanalys"

The reason why this works is because the error you encounter occurs as part of the code that attempts resolve a prefix path using the name. If you specify the path directly, then it doesn't have to run this resolve branch of the code.

like image 77
merv Avatar answered Oct 17 '22 03:10

merv


It should be conda remove --all --prefix "path" (i.e. remove should be without --), else it shows the following error (at least in my case):

conda: error: argument command: invalid choice: 'path'
(choose from 'clean', 'config', 'create', 'help', 'info', 'install', 'list', 'package', 'remove', 'uninstall', 'search', 'update', 'upgrade')

like image 35
afroditi Avatar answered Oct 17 '22 03:10

afroditi