当前位置: 首页 > 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.zskr.cn/news/25419.html

相关文章:

  • 2025年氧化镁厂家最新权威推荐榜:活性氧化镁,肥料级氧化镁,高纯度氧化镁源头厂家深度解析及选购指南
  • [随笔11] 最近的心情 - 枝-致
  • DxO Nik Collection 8.0:7 款专业摄影插件套装,一站式图像后期解决方案
  • 三款AI平台部署实战体验:Dify、扣子与BuildingAI深度对比
  • 2025年南通宠物医院权威推荐榜:专业诊疗与暖心服务口碑之选,精选优质宠物医疗机构
  • PPO GRPO GSPO DAPO的Loss计算与代码实现
  • 2025年铣边机/铣床/刨边机/滚轮架/变位机厂家推荐排行榜,专业实力与市场口碑深度解析
  • 详细介绍:php+vue新疆数字证书认证政府中心网站建设
  • UOJ #1005. 【UR #32】王之钦定 题解
  • YAML
  • 【ffmpeg】开发过程中错误简单记录
  • 2025 定制家具厂家推荐榜:定制酒柜/定制房门/定制护墙板/定制吧台/定制装饰柜/定制鞋柜/聚焦个性化与环保,这家深圳企业成优选​
  • 探索无限可能:生成式推荐的演进、前沿与挑战【AI业务应用方向】
  • 【隐语SecretFlow架构解读】隐私保护模型在线推理系统 SecretFlow-Serving 架构解读
  • 技术指标分享--单趋势通道
  • 2025 年宁波北仑仓库服务商推荐新世洋集团,港口物流仓储的专业之选宁波北仑仓库推荐
  • 2025年冲压件厂家权威推荐榜:新能源/光伏/精密/异形/五金/铝/汽配/不锈钢/家具冲压件源头实力解析
  • 2025年UV固化设备厂家推荐排行榜,UV面光源,UV LED点光源,UV LED面光源,UV LED固化机专业选购指南
  • stm32和Zynq的中断抢占机制 - 实践
  • 2025 年食品级润滑油源头厂家最新推荐排行榜:聚焦国产标杆企业,54 项专利加持,助力企业精准选品食品级润滑油液压油/食品级润滑油齿轮油/食品级润滑油烘焙设备润滑油厂家推荐
  • 2025年精密弹簧厂家权威推荐榜:压缩弹簧、拉伸弹簧、异形弹簧专业制造商实力解析与选购指南
  • 牛客刷题-Day15
  • 数据结构学习(1)——指针、结构体、链表(C语言) - 实践
  • rhel v7 v8 local repository setting
  • 【完整版】vcruntime140_1.dll缺失?3步快速修复教程(含官方修复工具+系统适配指南)
  • linux 学习平台 arm+x86 搭建 - 详解
  • 告别重复劳动,MonkeyCode 让你的开发团队拥有永动机
  • 自主进化的AI大模型架构设想(解决大模型时效性问题):知识网络的拓扑设计 - 详解
  • 2025 年大连 AI 品牌最新推荐排行榜:甄选懂商业重实效的实力服务商大连Ai培训/大连Ai开发/大连Ai推广公司推荐
  • 2025 年国内氧化锆陶瓷厂家最新推荐排行榜:含黑色 / 白色 / 电子陶瓷等品类公司精选