我正在尝试构建一个基本的机器学习算法,为此我使用 Python 的 Anaconda 解释器。但是,即使 Visual Studio Code 似乎已将 Conda 识别为解释器,并且我将 Anaconda 3 shell 作为单独的应用程序工作,但我无法让 Conda 在 Visual Studio Code 中工作。
每当我尝试检查 Conda 时,都会收到以下错误:
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda activate base
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (conda:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我已经尝试了此处链接的修复:“Conda”未被识别为内部或外部命令
但是,它们对我不起作用。我尝试将 Conda 设置为我的路径,但仍然遇到相同的错误。
为了让 python、anaconda 和 conda 与 VS Code 良好配合,我安装了 Python 扩展。
然后在 Python 扩展设置中,将
Python: Conda Path
设置为您的 conda.exe
,并将“Python:默认解释器路径”设置为您的 python.exe
。
对我来说,
conda.exe
路径位于...\Anaconda3\Library\Scripts\conda.exe
和 'python.exewas the conda base env one at
...\Anaconda3\python.exe`
解决此问题的两种方法。
a) 如果您已经设置了 Anaconda 环境。打开 Anaconda Navigator --> Home --> 启动 VS Code
这必须为 VS Code 编辑器正确配置所有 python 和 conda 路径。
b) 要进行验证,请在 VS Code 中安装 Python 扩展(如果尚未安装)。 然后转到命令面板 --> 首选项:打开用户设置 --> 扩展 --> Python
c) 然后搜索Python:default解释器路径。
和
Python:Conda 路径