每次打开 VScode 时自动激活 venv
我了解每次在 VScode 中打开新终端(使用 Python:选择解释器)时如何自动激活 venv (python),
但我找不到每次重新启动 VScode 时在终端中自动激活 venv 的方法。似乎我没有其他办法,只能在每次重新启动 VScode 时通过 Select Interpreter 重复激活 venv 的过程。有没有更方便的方法或更改 VScode 终端设置的方法,这样我就不必这样做?
谢谢。
我目前在 settings.json 中有这些设置
{
"python.terminal.activateEnvironment": true,
"python.defaultInterpreterPath": "source/venv/bin/activate",
}
I understand how to auto-activate venv (python) everytime I open new terminal in VScode (using Python: Select Interpreter)
but i can't find a way to auto-activate venv in terminal everytime i restart VScode. It seems like I have no other way than repeating the process of activating venv via Select Interpreter everytime i restart VScode. is there a more convenient way or a way to change VScode terminal setting so i don't have to do this?
thanks.
i have these settings in settings.json currently
{
"python.terminal.activateEnvironment": true,
"python.defaultInterpreterPath": "source/venv/bin/activate",
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为项目选择环境后,尽管您重新启动了 VSCode,VSCode 仍会记住它。您不需要再次选择 python 解释器。所以,我不清楚你的意思是环境问题还是终端环境问题。
但是你可以尝试在settings.json中添加这个:
并且你可以创建一个新的终端并通过Ctrl+Shift+`的快捷键激活终端中的环境
After you selected an environment for a project, the VSCode can remember it, although you have restarted the VSCode. You do not need to select the python interpreter again. So, I do not clearly know what you mean, the environment problem or the environment in the terminal problem.
But you can try to add this in the settings.json:
And you can create a new terminal and activate the environment in the terminal through the shortcut of Ctrl+Shift+`