英文:
vscode python venv - activate.ps1 is used instead of activate.bat
问题
在 vscode 用户设置中,"terminal.integrated.defaultProfile.windows" 已声明为 "Command Prompt"。
我已经在 vscode 中创建了一个 Python 虚拟环境 (venv)。
当在虚拟环境内部打开 vscode 时,会打开一个集成的 cmd 终端。自动执行命令 "& <正确的虚拟环境路径>/.venv/Scripts/Activate.ps1" 导致错误 "&" 无法在此处语法处理。
我本来期待,由于全局 cmd-shell 设置,自动执行的脚本应该是 "<正确的虚拟环境路径>/.venv/Scripts/activate.bat"。在集成终端中手动执行此脚本会正确激活环境。
我已尝试查找关于终端配置文件的文档,但未能使初始集成终端执行正确的脚本。
请问是否有人可以给我提供必要的配置变量提示。
英文:
In the vscode user settings "terminal.integrated.defaultProfile.windows": "Command Prompt" is declared.
I have created a python virtual env (venv) from within vscode.
When opening vscode from within the venv, an integrated cmd-terminal is opened. The command "& <correct path to venv>/.venv/Scripts/Activate.ps1" is automatically executed leading to the error ""&" kann syntaktisch an dieser Stelle nicht verarbeitet werden."
I would have awaited, that, due to the global cmd-shell setting, the automatically executed script would be "<correct path to venv>/.venv/Scripts/activate.bat". Executing this script manually in the integrated terminal leads to the correct activation of the environment.
I have tried what I have found in the documentation concerning terminal profiles but didn't manage to get the initial integrated terminal to execute the right script.
Could someone please give me a hint to the necessary configuration variable(s).
答案1
得分: 1
如果选择虚拟环境解释器,vscode将在构建新终端时自动激活该环境。
"python.terminal.activateEnvironment": true,
您的问题可能是由终端缓存引起的,添加以下设置以关闭记录终端会话历史记录。
"terminal.integrated.enablePersistentSessions": false,
英文:
If you choose a virtual environment interpreter, vscode will automatically activate the environment when you build a new terminal.
"python.terminal.activateEnvironment": true,
Your problem may be caused by the terminal cache, add the following setting to turn off recording terminal session history
"terminal.integrated.enablePersistentSessions": false,
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论