每当我试图激活Windows10上的VSCode中的conda时,我都会收到一条消息来初始化shell。
我尝试了以下方法
conda init bash
和重新启动VSCodeconda.bat activate
->没有更改。/c/Users/user/anaconda3/python
conda init bash
which python
计算机,通过F1 >which python
:选择解释器我认为问题在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 info
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
发布于 2020-07-29 18:49:18
您的“$”向我表示,您实际上没有打开命令行提示符,而是另一个选项(可能是bash?)。
按Ctrl+Shift+P并搜索“选择默认shell”,更改为命令行提示符,您应该可以转到:)
发布于 2021-05-17 08:06:55
我也遇到了类似的问题,但无法找到我所需要的明确的解决方案。我正在展示我发现的对我有用的鹅卵石解决方案,希望如果上面的答案对你无效的话,它可能会对你有用。
一种方法是进入注册表并修改ExecutionPolicy (我对此并不有信心)。
我的工作方式是按Ctrl+Shift+P in VSCode并打开"Preferences: open (Json)“并添加一个配置文件。
这修正了"CommandNotFoundError:您的shell没有被正确配置为使用'conda‘.“错误。
注意:这里的设置假设您使用powershell作为默认shell。这也修正了一些"&…“也有错误。出现此错误是因为"&“是一个PS (powershell)命令,如果您使用cmd.exe作为shell,则可能会弹出错误。
{...,
"python.pythonPath": "C:\\Users\\<user>\\miniconda3\\envs\\py39\\python.exe",
"python.condaPath": "C:\\Users\\<user>\\miniconda3\\Scripts\\conda.exe",
"terminal.integrated.cwd": "D:\\my_VSCode_storage\\py39_env\\my_project_folder",
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"python.terminal.executeInFileDir": true,
"args":["-NoLogo",
"-ExecutionPolicy",
"Bypass",
"-NoExit",
"-Command",
"& C:\\Users\\<user>\\miniconda3\\shell\\condabin\\conda-hook.ps1",
";conda activate 'C:\\Users\\<user>\\miniconda3'"
]
},
...}
发布于 2021-10-20 18:30:04
按照https://stackoverflow.com/a/69127741/11262633,执行conda init
。随后的运行将正确地执行对conda
的所需调用。
https://stackoverflow.com/questions/63160357
复制相似问题