-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Type: Bug
Behaviour
Actual behaviour:
When using the "Python: Create Environment" command to create a path-based Conda environment (in the default ".conda" folder), the automatic terminal activation feature (python.terminal.activateEnvInCurrentTerminal) incorrectly tries to activate it by name (conda activate .conda), which fails with an EnvironmentNameNotFound error.
Expected behaviour:
When a path-based Conda environment is created using the Python: Create Environment command, the python.terminal.activateEnvInCurrentTerminal feature should correctly identify this environment as path-based. Consequently, it should use the environment's full path for activation (e.g., conda activate "d:\path\to\project\.conda") instead of incorrectly attempting to activate it by name.
Steps to reproduce:
-
On a clean Windows system with a fresh Miniconda installation, run
conda init powershell. -
Open a project folder in VS Code, preferably with spaces in its path (e.g.,
D:\test folder). -
Create a new file and save it with a
.pyextension (e.g.,app.py). This ensures the Python extension is fully activated. -
Open the Command Palette (
Ctrl+Shift+P) and run "Python: Create Environment". -
Select "Conda" as the environment type.
-
Choose any Python version (e.g., 3.11).
-
Wait for the environment to be successfully created in the local
.condafolder. -
Terminate any active terminal instances (e.g., using the trash can icon). Then, open a new integrated terminal using the `Ctrl + `` shortcut.
-
Observe that the terminal automatically tries to run
conda activate .condaand fails.
Diagnostic data
launch.json configuration
N/A (Not Applicable). The issue occurs without a `launch.json` file.
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2025-08-07 20:39:41.197 [info] Running Conda Env creation script: [
'D:\\Miniconda3\\python.exe',
'c:\\Users\\Administrator\\.vscode\\extensions\\ms-python.python-2025.10.1-win32-x64\\python_files\\create_conda.py',
'--git-ignore',
'--install',
'--python',
'3.11'
]
2025-08-07 20:39:41.197 [info] > D:\Miniconda3\python.exe ~\.vscode\extensions\ms-python.python-2025.10.1-win32-x64\python_files\create_conda.py --git-ignore --install --python 3.11
2025-08-07 20:39:41.197 [info] cwd: d:\vsc python\py machine
2025-08-07 20:39:41.254 [info] Running: D:\Miniconda3\python.exe -m conda create --yes --prefix .conda python=3.11
2025-08-07 20:39:42.315 [info] 3 channel Terms of Service accepted
2025-08-07 20:39:42.315 [info] WARNING conda.core.prefix_data:validate_path(324): Environment paths should not contain spaces. Prefix: 'd:\vsc python\py machine\.conda'
2025-08-07 20:39:42.821 [info] Channels:
- defaults
Platform: win-64
Collecting package metadata (repodata.json): -
2025-08-07 20:39:45.822 [info] done
Solving environment:
2025-08-07 20:39:45.923 [info] done
2025-08-07 20:39:45.924 [info] ==> WARNING: A newer version of conda exists. <==
current version: 25.5.1
latest version: 25.7.0
Please update conda by running
$ conda update -n base -c defaults conda
2025-08-07 20:39:45.937 [info] ## Package Plan ##
environment location: d:\vsc python\py machine\.conda
added / updated specs:
- python=3.11
The following NEW packages will be INSTALLED:
bzip2 pkgs/main/win-64::bzip2-1.0.8-h2bbff1b_6
ca-certificates pkgs/main/win-64::ca-certificates-2025.2.25-haa95532_0
expat pkgs/main/win-64::expat-2.7.1-h8ddb27b_0
libffi pkgs/main/win-64::libffi-3.4.4-hd77b12b_1
openssl pkgs/main/win-64::openssl-3.0.17-h35632f6_0
pip pkgs/main/noarch::pip-25.1-pyhc872135_2
python pkgs/main/win-64::python-3.11.13-h981015d_0
setuptools pkgs/main/win-64::setuptools-78.1.1-py311haa95532_0
sqlite pkgs/main/win-64::sqlite-3.50.2-hda9a48d_1
tk pkgs/main/win-64::tk-8.6.14-h5e9d12e_1
tzdata pkgs/main/noarch::tzdata-2025b-h04d1e81_0
ucrt pkgs/main/win-64::ucrt-10.0.22621.0-haa95532_0
vc pkgs/main/win-64::vc-14.3-h2df5915_10
vc14_runtime pkgs/main/win-64::vc14_runtime-14.44.35208-h4927774_10
vs2015_runtime pkgs/main/win-64::vs2015_runtime-14.44.35208-ha6b5a95_10
wheel pkgs/main/win-64::wheel-0.45.1-py311haa95532_0
xz pkgs/main/win-64::xz-5.6.4-h4754444_1
zlib pkgs/main/win-64::zlib-1.2.13-h8cc25b3_1
2025-08-07 20:39:45.937 [info] Downloading and Extracting Packages: ...working... done
Preparing transaction:
2025-08-07 20:39:46.053 [info] done
2025-08-07 20:39:46.053 [info] Verifying transaction: |
2025-08-07 20:39:47.168 [info] done
2025-08-07 20:39:47.169 [info] Executing transaction:
2025-08-07 20:39:49.970 [info] Discover tests for workspace name: py machine - uri: d:\vsc python\py machine\.conda\Lib\site-packages\pkg_resources\tests\data\my-test-package-source\setup.cfg
2025-08-07 20:39:52.483 [info] done
2025-08-07 20:39:52.498 [info] #
# To activate this environment, use
#
# $ conda activate "d:\vsc python\py machine\.conda"
#
# To deactivate an active environment, use
#
# $ conda deactivate
2025-08-07 20:39:52.591 [info] CREATED_CONDA_ENV:d:\vsc python\py machine\.conda
2025-08-07 20:39:52.591 [info] Creating: d:\vsc python\py machine\.conda\.gitignore
2025-08-07 20:39:52.611 [info] Active interpreter [d:\vsc python\py machine]: d:\vsc python\py machine\.conda\python.exe
2025-08-07 20:39:52.613 [info] Discover tests for workspace name: py machine - uri: d:\vsc python\py machine
2025-08-07 20:39:52.613 [info] Python 解释器路径: .\.conda\python.exe
2025-08-07 20:41:32.511 [info] Send text to terminal: D:/Miniconda3/Scripts/activate
2025-08-07 20:41:33.024 [info] Send text to terminal: conda activate .conda
```powershell
(base) PS D:\vsc python\py machine> D:/Miniconda3/Scripts/activate
(base) PS D:\vsc python\py machine> conda activate .conda
EnvironmentNameNotFound: Could not find conda environment: .conda
You can list all discoverable environments with `conda info --envs`.
Invoke-Expression : 无法将参数绑定到参数“Command”,因为该参数为空字符串。
所在位置 D:\Miniconda3\shell\condabin\Conda.psm1:76 字符: 36
+ Invoke-Expression -Command $activateCommand;
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Expression],ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.InvokeExp
ressionCommand
Output for Python Debugger in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python Debugger)
N/A
Extension version: 2025.10.0
VS Code version: Code 1.98.2 (ddc367ed5c8936efe395cffeec279b04ffd7db78, 2025-03-12T13:32:45.399Z)
OS version: Windows_NT x64 10.0.26100
Modes: Unsupported
- Python version (& distribution if applicable, e.g. Anaconda): 3.11.13
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
Details
| Item | Value |
|---|---|
| CPUs | 12th Gen Intel(R) Core(TM) i5-12600KF (16 x 3686) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | undefined |
| Memory (System) | 31.82GB (14.84GB free) |
| Process Argv | --crash-reporter-id 794c9ebe-4943-4fd5-b62d-f4683b3b589a |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
binariesv615:30325510
h48ei257:31000450
nativeloc1:31344060
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31277805
pythoneinst12:31285622
c7cif404:31314491
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
0aa6g176:31307128
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
pylancequickfixf:31358881
convertlamdat:31358880
usemarketplace:31343026
testaa123cf:31335227
onetestforazureexpcf:31335614
6abeh943:31336334
yijiwantestdri0626-t:31336930
0927b901:31350571
4gdec884:31348710