每次打开 VScode 时自动激活 venv

发布于 2025-01-17 02:37:18 字数 444 浏览 1 评论 0原文

我了解每次在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洛阳烟雨空心柳 2025-01-24 02:37:19

为项目选择环境后,尽管您重新启动了 VSCode,VSCode 仍会记住它。您不需要再次选择 python 解释器。所以,我不清楚你的意思是环境问题还是终端环境问题。

但是你可以尝试在settings.json中添加这个:

"python.terminal.activateEnvInCurrentTerminal": true,

并且你可以创建一个新的终端并通过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:

"python.terminal.activateEnvInCurrentTerminal": true,

And you can create a new terminal and activate the environment in the terminal through the shortcut of Ctrl+Shift+`

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文