I’m trying to use conda, python with VS Code.
Everything works well in windows terminal, but after I relaunch vscode terminal, every conda commands doesn’t work on vscode terminal (except activate and deactivate).
-
conda command works at first activation
Fist activtion -
Error After Relaunch
(dl) C:Users{USERNAME}DocumentsVScode Workspacepytorch>conda env list
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "C:Users{USERNAME}anaconda3Libsite-packagescondaexception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:Users{USERNAME}anaconda3Libsite-packagescondaclimain.py", line 54, in main_subshell
parser = generate_parser(add_help=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:Users{USERNAME}anaconda3Libsite-packagescondacliconda_argparse.py", line 127, in generate_parser
configure_parser_plugins(sub_parsers)
File "C:Users{USERNAME}anaconda3Libsite-packagescondacliconda_argparse.py", line 354, in configure_parser_plugins
else set(find_commands()).difference(plugin_subcommands)
^^^^^^^^^^^^^^^
File "C:Users{USERNAME}anaconda3Libsite-packagescondaclifind_commands.py", line 71, in find_commands
for entry in os.scandir(dir_path):
^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 123] The filename, directory name, or volume label syntax is
incorrect: '.C:\WINDOWS\system32'
`$ C:Users{USERNAME}anaconda3Scriptsconda-script.py env list`
environment variables:
CIO_TEST=<not set>
CONDA_DEFAULT_ENV=dl
CONDA_EXE=C:Users{USERNAME}anaconda3condabin..Scriptsconda.exe
CONDA_EXES="C:Users{USERNAME}anaconda3condabin..Scriptsconda.exe"
CONDA_PREFIX=C:Users{USERNAME}anaconda3envsdl
CONDA_PROMPT_MODIFIER=(dl)
CONDA_PYTHON_EXE=C:Users{USERNAME}anaconda3python.exe
CONDA_ROOT=C:Users{USERNAME}anaconda3
CONDA_SHLVL=1
CURL_CA_BUNDLE=<not set>
HOMEPATH=Users{USERNAME}
LD_PRELOAD=<not set>
PATH=C:Users{USERNAME}anaconda3envsdl;C:UsersLAPTOP-
PNEanaconda3envsdlLibrarymingw-w64bin;C:UsersLAPTOP-
PNEanaconda3envsdlLibraryusrbin;C:UsersLAPTOP-
PNEanaconda3envsdlLibrarybin;C:UsersLAPTOP-
PNEanaconda3envsdlScripts;C:UsersLAPTOP-
PNEanaconda3envsdlbin;C:Users{USERNAME}anaconda3condabin;C:WI
NDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32
WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program
FilesBandizip;C:Program FilesMicrosoft SQL
Server150ToolsBinn;C:Program FilesMicrosoft SQL ServerClient
SDKODBC170ToolsBinn;C:Program Filesdotnet;C:UsersLAPTOP-
PNEAppDataLocalMicrosoftWindowsApps;C:UsersLAPTOP-
PNE.dotnettools;C:Users{USERNAME}AppDataLocalProgramsMicrosoft
VS Codebin;C:Users{USERNAME}anaconda3;C:UsersLAPTOP-
PNEanaconda3Library;C:Users{USERNAME}anaconda3Scripts;.C:WINDOW
Ssystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32Win
dowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program
FilesBandizip;C:Program FilesMicrosoft SQL
Server150ToolsBinn;C:Program FilesMicrosoft SQL ServerClient
SDKODBC170ToolsBinn;C:Program Filesdotnet;C:UsersLAPTOP-
PNEAppDataLocalMicrosoftWindowsApps;C:UsersLAPTOP-
PNE.dotnettools;C:Users{USERNAME}AppDataLocalProgramsMicrosoft
VS Codebin;C:Users{USERNAME}anaconda3;C:UsersLAPTOP-
PNEanaconda3Library;C:Users{USERNAME}anaconda3Scripts;
PSMODULEPATH=C:Program FilesWindowsPowerShellModules;C:WINDOWSsystem32Windows
PowerShellv1.0Modules
PYTHONIOENCODING=utf-8
PYTHONUNBUFFERED=1
PYTHONUTF8=1
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=C:Users{USERNAME}anaconda3envsdlLibrarysslcacert.pem
active environment : dl
active env location : C:Users{USERNAME}anaconda3envsdl
shell level : 1
user config file : C:Users{USERNAME}.condarc
populated config files : C:Users{USERNAME}.condarc
conda version : 23.7.4
conda-build version : 3.26.1
python version : 3.11.5.final.0
virtual packages : __archspec=1=x86_64
__cuda=11.2=0
__win=0=0
base environment : C:Users{USERNAME}anaconda3 (writable)
conda av data dir : C:Users{USERNAME}anaconda3etcconda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:Users{USERNAME}anaconda3pkgs
C:Users{USERNAME}.condapkgs
C:Users{USERNAME}AppDataLocalcondacondapkgs
envs directories : C:Users{USERNAME}anaconda3envs
C:Users{USERNAME}.condaenvs
C:Users{USERNAME}AppDataLocalcondacondaenvs
platform : win-64
user-agent : conda/23.7.4 requests/2.31.0 CPython/3.11.5 Windows/10 Windows/10.0.22621
administrator : False
netrc file : None
offline mode : False
I think it’s conda env or python extension problem.
When conda env activated, system paths are modified appending single dot at the last of path.
And Python Extension also modify system path by appending {envPath} to it.
Concatanation of dot and envpath create an invalid path (i.e.,".C:System32")
Disabling Python Extension’s Activate Environment option could prevent error, but it also disable conda env auto activation.
Plus, I found that dot ‘.’ at the last of system path doesn’t removed after deactivate conda
>echo %PATH%
C:Users{USERNAME}anaconda3condabin; (...) C:Users{USERNAME}anaconda3Scripts;
>conda activate
(base)>echo %PATH%
C:Users{USERNAME}anaconda3; (...) C:Users{USERNAME}anaconda3Scripts;.
(base)>conda deactivate
>echo %PATH%
C:Users{USERNAME}anaconda3condabin; (...) C:Users{USERNAME}anaconda3Scripts;.
2
Answers
This should be an error caused by a plugin, just use
conda --no-plugins env list
to temporarily disable the plugin.This is a bug: A drive with the name ‘.C’ does not exist #22047.
The fix has been made in Make sure
PATH
ends with a separator before prepending #22046 in the pre-release channel of the Python extension.Another (worse) solution: One user, kwikwag, has found a temporary workaround to put
$env:Path = $env:Path.replace('.c','.;c')
in theirprofile.ps1
file.