如何让 Python 调试任务使用默认的 Powershell 配置文件? [英] How to make the Python debug task use the default Powershell profile?
问题描述
我试图在调试模式下运行 Python 文件,但我收到错误消息,因为它启动的 Powershell 集成终端是空的.为了让它工作,我希望它使用以下配置文件首先初始化 Anaconda env.
I am trying to run a Python file in debug mode, and I get an error because the Powershell integrated terminal it starts is bare. To get it to work, I want it to use the following profile which initializes the Anaconda env first.
"terminal.integrated.profiles.windows": {
"PowerShell -conda": {
"source": "PowerShell",
"args": ["-ExecutionPolicy", "ByPass", "-NoExit", "-Command", "& 'C:/Users/Marko/anaconda3/shell/condabin/conda-hook.ps1' ; conda activate 'C:/Users/Marko/anaconda3'"]
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell -conda"
我应该怎么做才能做到这一点?
What should I do to make that happen?
推荐答案
您需要先初始化 conda.
You need to init conda first.
在任何终端中运行 conda init
命令.
Run conda init
command in any terminal.
它将在 C:\Users{UserName}\Documents\WindowsPowerShell 文件夹下创建一个 profile.ps1 文件.
It will create a profile.ps1 file under the folder of C:\Users{UserName}\Documents\WindowsPowerShell.
之后,如果您打开 PowerShell,conda 将起作用.它等于 C:/Users/Marko/anaconda3/shell/condabin/conda-hook.ps1
After that, if you open the PowerShell, conda will work. It equals to C:/Users/Marko/anaconda3/shell/condabin/conda-hook.ps1
这篇关于如何让 Python 调试任务使用默认的 Powershell 配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!