VSCode / Virtual Studio Code: Unable to Load Conda Environment in VSCode Terminal(VSCode/Virtual Studio Code:无法在 VSCode 终端中加载 Conda 环境)
问题描述
我正在尝试切换到 VScode,使用内置终端与 Anaconda 交互,并且知道 VScode 支持 Anaconda,因为它随 Anaconda 一起提供.
I'm attempting to switch to VScode, to use the built-in terminal to interact with Anaconda, and know VScode supports Anaconda because it ships with Anaconda.
从文档和各种教程/视频中,我看到 conda/虚拟环境已被识别(似乎是本机的).但我似乎无法弄清楚.
From the documentation, and various tutorials/videos, I see that the conda/virtual environments are recognized (seemingly natively). And yet I cannot seem to figure it out.
使用我想在 VScode 中打开的 python 脚本,我确保我使用了正确的解释器/环境,如下所示:ctrl+shift+p 加载命令面板Python:选择解释器C:...Anaconda3envsp3audiopython.exe
With the python script I want to run open in VScode, I ensure that I am using the correct interpreter/environment as follows: ctrl+shift+p to load Command Pallette Python:Select Interpreter C:...Anaconda3envsp3audiopython.exe
在窗口底部,当我加载 p3audio 环境以使用 python 3.7 时,环境似乎也指向环境,这就是显示的内容('Anaconda Python 3.7.0')(顶部的 Python 在我相信顶级 anaconda 附带 3.6)
At the bottom of the window, the environment also appears to be pointing to the environment as I loaded the p3audio environment to use python 3.7 and this is what is showing ('Anaconda Python 3.7.0') (The top Python in top level anaconda is shipped with 3.6 I believe)
当我尝试通过终端菜单中的运行活动文件"运行 python 文件时,它会自动加载 powershell 并将其执行到终端中:
When I try to run the python file by 'Run Active File' from the Terminal Menu, it automatically loads powershell and executes this into the terminal:
PS C:...Anaconda3envs> c:...Anaconda3envsProjectsp3audo_projectsmy_script.py
PS C:...Anaconda3envs> c:...Anaconda3envsProjectsp3audo_projectsmy_script.py
(第二条路径为黄色)
如果我尝试从 powershell 终端手动激活 conda 环境,它无法识别它.
If I try to activate the conda environment manually from the powershell terminal, it doesn't recognize it.
我可以从 anaconda 提示终端正常运行脚本.
I can run the script fine from the anaconda prompt terminal.
我认为这可能是一个路径问题,但我使用的所有文档/资源都表明,如果我没有选择(打勾)在安装时添加路径,我不应该有这个问题.我检查了我的环境变量路径,上面没有 anaconda.
I think it may be a path issue, but all of the documentation/resources I used suggest I shouldn't have the issue if I didn't select (tick the box) for add path on install. I checked my environment variable path and don't have anaconda on it.
我想知道它是否与在终端窗口中加载的您可以通过选择自定义按钮来更改默认终端外壳"有关.这让我相信我必须在某处手动添加 conda 终端路径.但这让我感到惊讶,因为 vscode 附带 anaconda,而我在文档中没有看到任何提及.
I am wondering if it has to do with the 'you can change the default terminal shell by selecting the customize button' that loads in the terminal window. This leads me to believe that I have to manually add the conda terminal path somewhere. But this surprises me because, vscode shipped with anaconda, and I see no mention of this in the documentation.
我显然是这方面的新手,并且多次遇到环境变量/路径问题.但我想不通.
I am obviously a newbie at this, and have suffered through environment variable/path issues many times. But I can't figure this out.
任何帮助将不胜感激.
谢谢
推荐答案
在最近的 conda 版本 (4.6.1) 中,Conda 现在可以在 Powershell 中初始化,现在可以干净地集成到 VSCode 中.我在这里发了一个stackoverflow帖子
With the recent conda release (4.6.1) Conda can now be initialized in Powershell and can now be integrated in VSCode cleanly. I made a stackoverflow post here
这篇关于VSCode/Virtual Studio Code:无法在 VSCode 终端中加载 Conda 环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:VSCode/Virtual Studio Code:无法在 VSCode 终端中加载 C
基础教程推荐
- Python 的 List 是如何实现的? 2022-01-01
- 如何在Python中绘制多元函数? 2022-01-01
- 使 Python 脚本在 Windows 上运行而不指定“.py";延期 2022-01-01
- 症状类型错误:无法确定关系的真值 2022-01-01
- 使用Python匹配Stata加权xtil命令的确定方法? 2022-01-01
- 哪些 Python 包提供独立的事件系统? 2022-01-01
- 如何在 Python 中检测文件是否为二进制(非文本)文 2022-01-01
- 合并具有多索引的两个数据帧 2022-01-01
- 将 YAML 文件转换为 python dict 2022-01-01
- 使用 Google App Engine (Python) 将文件上传到 Google Cloud Storage 2022-01-01