动态

详情 返回 返回

Windows 10 VSCode 激活 conda 虛擬環境失敗 - 动态 详情

問題背景

第一次在VSCode配置python Django開發環境
Anaconda管理Python虛擬環境
VSCode terminal powershell 激活創建好的虛擬環境
報錯信息:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

解決步驟

在 VScode terminal powershell 中執行

conda init

後重啓vscode,忽略錯誤信息進行下一步。

Windows10 全局搜關鍵字 powershell 以管理員權限打開,輸入命令

set-ExecutionPolicy RemoteSigned

再輸入一個y點回車確定執行命令就行。

再重啓一下Vscode terminal powershell 輸入命令

conda activate [虛擬環境名稱]

就能發現終於正確切換 conda 虛擬環境了。

Add a new 评论

Some HTML is okay.