当前位置: 首页 > news >正文

版本号搞得鬼!Winsows VSCode 和 Trae 的 Terminal 不识别 conda 环境

问题简述

在 Win 11 系统自带的终端(Powershell)和CMD窗口中,可以正常调用conda,命令行回显:

(base) PS C:\Users\DELL>

然而,在 VSCode 和 Trae 上无法正确使用 conda 报错为:

PS C:\Users\DELL> conda activate base  
Invoke-Expression: Missing '{' in configuration statement.

版本号

在 CMD 窗口中,$PSVersionTable 命令无效。
在 Windows Powershell 窗口中,$PSVersionTable 命令回显:

(base) PS C:\Users\DELL>  $PSVersionTableName                           Value
----                           -----
PSVersion                      5.1.26100.6899
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.6899
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

在VSCode的Terminal窗口中,$PSVersionTable 命令回显:

PS C:\Users\DELL>  $PSVersionTableName                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

尝试1:使用 conda init powershell

在 Windows Powershell 中执行后回显:

(base) PS C:\Users\DELL> conda init
no change     D:\software\miniconda\Scripts\conda.exe
no change     D:\software\miniconda\Scripts\conda-env.exe
no change     D:\software\miniconda\Scripts\conda-script.py
no change     D:\software\miniconda\Scripts\conda-env-script.py
no change     D:\software\miniconda\condabin\conda.bat
no change     D:\software\miniconda\Library\bin\conda.bat
no change     D:\software\miniconda\condabin\_conda_activate.bat
no change     D:\software\miniconda\condabin\rename_tmp.bat
no change     D:\software\miniconda\condabin\conda_auto_activate.bat
no change     D:\software\miniconda\condabin\conda_hook.bat
no change     D:\software\miniconda\Scripts\activate.bat
no change     D:\software\miniconda\condabin\activate.bat
no change     D:\software\miniconda\condabin\deactivate.bat
no change     D:\software\miniconda\Scripts\activate
no change     D:\software\miniconda\Scripts\deactivate
no change     D:\software\miniconda\etc\profile.d\conda.sh
no change     D:\software\miniconda\etc\fish\conf.d\conda.fish
no change     D:\software\miniconda\shell\condabin\Conda.psm1
no change     D:\software\miniconda\shell\condabin\conda-hook.ps1
no change     D:\software\miniconda\Lib\site-packages\xontrib\conda.xsh
no change     D:\software\miniconda\etc\profile.d\conda.csh
no change     C:\Users\DELL\Documents\PowerShell\profile.ps1
no change     C:\Users\DELL\Documents\WindowsPowerShell\profile.ps1
no change     HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
No action taken.

尝试在 VSCode 中执行相同的命令,回显:

PS C:\Users\DELL> conda init powershell
usage: conda-script.py [-h] [-V] command ...conda is a tool for managing and deploying applications, environments and packages.Options:positional arguments:commandclean             Remove unused packages and caches.compare           Compare packages between conda environments.config            Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file (C:\Users\DELL\.condarc) by default. Use the    --show-sources flag to display all identified configuration locations on your computer.create            Create a new conda environment from a list of specified packages.info              Display information about current conda install.init              Initialize conda for shell interaction.install           Installs a list of packages into a specified conda environment.list              List installed packages in a conda environment.package           Low-level conda package utility. (EXPERIMENTAL)remove (uninstall)Remove a list of packages from a specified conda environment. Use `--all` flag to remove all packages and the environment itself.rename            Renames an existing environment.run               Run an executable in a conda environment.search            Search for packages and display associated information.The input is a MatchSpec, a query language for conda packages. See examples below.update (upgrade)  Updates conda packages to the latest compatible version.notices           Retrieves latest channel notifications.optional arguments:-h, --help          Show this help message and exit.-V, --version       Show the conda version number and exit.conda commands available from other packages:doctor - A subcommand that displays environment health report

实际上并没有被调用起来。

解决

Conda在PowerShell 7.5版本中会失效。可以通过升级 conda 软件来处理。

https://zhuanlan.zhihu.com/p/22881718447
https://github.com/conda/conda/issues/14292#issuecomment-2619710240
https://github.com/PowerShell/PowerShell/issues/24869#issuecomment-2625708821

  1. 首先切换到 base 环境 conda activate base
  2. 升级 python 版本 conda update python (按需指定版本号)
  3. 升级 conda 版本 conda update conda (按需指定版本号)

即解决。

http://www.jsqmd.com/news/17603/

相关文章:

  • 2025年氧化镁厂家最新权威推荐榜:活性氧化镁,肥料级氧化镁,高纯度氧化镁源头厂家深度解析及选购指南
  • 客户端使用ceph服务器的块设备
  • [随笔11] 最近的心情 - 枝-致
  • 2025年智能照明系统/模块厂家推荐排行榜,工厂/车间/改建/高亮/高光效/泛光/免维护/投光/大功率智能照明系统及模块公司精选
  • DxO Nik Collection 8.0:7 款专业摄影插件套装,一站式图像后期解决方案
  • 启动JAVA
  • 2025年通风天窗厂家最新权威推荐榜:通风天窗,排烟天窗,通风气楼,屋顶通风器,顺坡气楼,10A通风天窗,1型通风天窗,TC5A通风天窗,TC12B通风天窗,屋脊通风天窗专业制造与高效通风解决方案
  • 三款AI平台部署实战体验:Dify、扣子与BuildingAI深度对比
  • #OO之接口-DAO模式代码阅读及应用
  • 2025年南通宠物医院权威推荐榜:专业诊疗与暖心服务口碑之选,精选优质宠物医疗机构
  • PPO GRPO GSPO DAPO的Loss计算与代码实现
  • P3601 签到题
  • 图像采集卡重要功能解析:打通视频信号处理全链路
  • 2025年铣边机/铣床/刨边机/滚轮架/变位机厂家推荐排行榜,专业实力与市场口碑深度解析
  • [Ubuntu]在windows系统上下载chrome browser .deb 文件
  • 详细介绍:php+vue新疆数字证书认证政府中心网站建设
  • 2025年机械加工厂家推荐排行榜,钣金加工,焊接件加工,零件加工,天文台圆顶加工,非标自动化设备加工设计,精密钣金加工,精密零件加工,金属加工公司推荐
  • A3979
  • UOJ #1005. 【UR #32】王之钦定 题解
  • 《C++ string类深度解析:核心接口全方位精讲与掌握》 - 指南
  • HL7v3和RIM是什么,和传统HL7,FHIR有什么关系
  • AtCoder AGC047 总结
  • YAML
  • QUALIFY 窗口过滤 - --
  • 【ffmpeg】开发过程中错误简单记录
  • 2025 定制家具厂家推荐榜:定制酒柜/定制房门/定制护墙板/定制吧台/定制装饰柜/定制鞋柜/聚焦个性化与环保,这家深圳企业成优选​
  • Winform开发报表(锐浪推方式)
  • 2025年通风天窗厂家最新权威推荐榜:排烟天窗、通风气楼、屋顶通风器、顺坡气楼、10A通风天窗、1型通风天窗、TC5A通风天窗、TC12B通风天窗、屋脊通风天窗专业选购指南
  • 【LeetCode】125. 验证回文串
  • Toposort