【问题标题】:Automatically activating conda environment in integrated terminal在集成终端中自动激活 conda 环境
【发布时间】:2021-09-13 21:28:03
【问题描述】:

我有一个想要使用的 anaconda 虚拟环境。我可以使用Select Interpreter,它可以找到并允许我准确地选择所述虚拟环境。我也可以将它与 jupyter 笔记本一起使用。我不能做的是让集成终端自动激活这个环境。

每次我打开一个新终端时,我都有:

(base) PS C:\working_folder

如果我在集成终端中手动激活环境,我就可以使用它。我的问题是我不想记住手动激活它。

我尝试过的事情:

  • "Python.terminal.activateEnvironment" 设置为true
  • "Python.terminal.activateEnvInCurrentTerminal" 设置为true
  • 在我的工作文件夹settings.json 中更新pythonPath

【问题讨论】:

  • 我想知道你是否得到了我的答案?您的问题解决了吗?
  • 是的,谢谢,这解决了我的问题。

标签: python visual-studio-code vscode-settings


【解决方案1】:

打开Powershell并以管理员身份运行,执行以下命令

conda config --set auto_activate_base true

然后重启VS Code,在User Settings.json中添加如下内容:

"python.defaultInterpreterPath": "\\path\\to\\conda\\python.exe",
"Python.terminal.activateEnvironment": true,
"Python.terminal.activateEnvInCurrentTerminal": true

Reload Window从Command Palette,选择base:conda作为python解释器然后按Ctrl+Shift+`打开一个新的集成终端,conda环境应该会自动激活它。

【讨论】:

    猜你喜欢
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 2019-04-30
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多