usage: conda-script.py [-h] [-v] [--no-plugins] [-V] COMMAND ...
conda-script.py: error: argument COMMAND: invalid choice: '' (choose from 'activate', 'clean', 'commands', 'compare', 'config', 'create', 'deactivate', 'env', 'export', 'info', 'init', 'install', 'list', 'notices', 'package', 'content-trust', 'doctor', 'repoquery', 'pack', 'tree', 'remove', 'uninstall', 'rename', 'run', 'search', 'update', 'upgrade')
문제 발생
Window PowerShell 7.5.0, miniconda 24.11 버젼 사용중 갑자기 뜬 에러이다.
conda 명령의 argument 파싱을 잘못하는 이상한 오류같은데, 잘 사용하다가 갑자기 떠서 당황했다.
conda의 컨텍스트 처리 과정에서 뭔가 문제가 있어서, 발생한 듯 한데 업데이트를 확인해도 뭐 딱히 고쳐지지 않았었다.
해결과정은 그냥 직접 psm 스크립트 수정해주기.
해결
- conda 설치 디렉토리를 찾아서, 'Conda.psm1' 을 검색해서 아무 에디터로 연다.(대부분 'pkgs'디렉토리 아래 여러 버젼에 해당하는, 'conda-xx.xx/shell/condabin' 디렉토리 아래로 있을 것이다. 수정하지 않았다면, 최신 버젼을 사용중일테니, 제일 이후 날짜의 디렉토리로 접근하자.)
- 'Invoke-Conda' 함수 부분을 찾아 아래 코드를 붙여넣기 해서 수정한다.
function Invoke-Conda() { # Don't use any explicit args here, we'll use $args and tab completion # so that we can capture everything, INCLUDING short options (e.g. -n). if ($Args.Count -eq 0) { # No args, just call the underlying conda executable. & $Env:CONDA_EXE $Env:_CE_M $Env:_CE_CONDA; } else { $Command = $Args[0]; if ($Args.Count -ge 2) { $OtherArgs = $Args[1..($Args.Count - 1)]; } else { $OtherArgs = @(); } switch ($Command) { "activate" { Enter-CondaEnvironment @OtherArgs; $Env:_CE_M = $null; $Env:_CE_CONDA = $null; } "deactivate" { Exit-CondaEnvironment; $Env:_CE_M = $null; $Env:_CE_CONDA = $null; } default { # There may be a command we don't know want to handle # differently in the shell wrapper, pass it through # verbatim. & $Env:CONDA_EXE $Env:_CE_M $Env:_CE_CONDA $Command @OtherArgs; } } } }