gpt4 book ai didi

python - 如何在 Windows 10 上的 VSCode 中激活 conda 环境

转载 作者:行者123 更新时间:2023-12-02 16:33:25 27 4
gpt4 key购买 nike

每当我尝试在 Windows 10 上的 VSCode 中激活 conda 时,我都会收到一条初始化 shell 的消息。

我尝试了以下方法

  • conda init bash 并重启 VSCode
  • conda.bat activate -> 无变化。 which python 仍然指向 /c/Users/user/anaconda3/python
  • conda init bash 之后重新启动计算机
  • 通过 F1 > Python:Select Interpreter 设置解释器

我认为问题出在 VSCode 中,因为我可以从 cmd、powershell、gitbash 和 PyCharm 终端中激活 conda

我错过了什么吗?

$ conda activate data_science
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'.

conda 信息

     active environment : None
user config file : C:\Users\user\.condarc
populated config files :
conda version : 4.8.3
conda-build version : 3.18.11
python version : 3.7.6.final.0
virtual packages : __cuda=11.0
base environment : C:\Users\user\anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\user\anaconda3\pkgs
C:\Users\user\.conda\pkgs
C:\Users\user\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\user\anaconda3\envs
C:\Users\user\.conda\envs
C:\Users\user\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.8.3 requests/2.22.0 CPython/3.7.6 Windows/10 Windows/10.0.18362
administrator : False
netrc file : None
offline mode : False

最佳答案

你的“$”向我表明你实际上没有打开命令行提示符,而是打开了一个替代方法(可能是 bash?)。

按 Ctrl+Shift+P 并搜索“Select default shell”,更改为 Command Line prompt,你应该可以开始了:)

enter image description here

关于python - 如何在 Windows 10 上的 VSCode 中激活 conda 环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63160357/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com