[英]How can I get rid of unnecessary paths being printed in Visual studio Code Terminal?
Every time I run my python script in VScode I get the following lines printed in the terminal:每次我在 VScode 中运行 python 脚本时,都会在终端中打印以下行:
Microsoft Windows [Version 10.0.19041.630]
(c) 2020 Microsoft Corporation. All rights reserved.
E:\My Laptop\Coding\Python\Study files\Projects>C:/ProgramData/Anaconda3/Scripts/activate
(base) E:\My Laptop\Coding\Python\Study files\Projects>conda activate base
(base) E:\My Laptop\Coding\Python\Study files\Projects>C:/ProgramData/Anaconda3/python.exe "e:/My Laptop/Coding/Python/Study files/Projects/100_Clean.py"
than program executes normally.比程序正常执行。 When execution ends, I get this line:当执行结束时,我得到这一行:
(base) E:\My Laptop\Coding\Python\Study files\Projects>
Why are these lines being printed?为什么要打印这些行? How can i turn them off in VSCode settings?如何在 VSCode 设置中关闭它们?
To my knowledge, there is no way to hide the paths because the VS Code Integrated Terminal is basically using your OS/system's underlying terminal.据我所知,没有办法隐藏路径,因为 VS Code 集成终端基本上是在使用您的操作系统/系统的底层终端。 And running Python scripts on a terminal usually requires you to specify a path.在终端上运行 Python 脚本通常需要您指定路径。
One workaround is to use "prompt" command in the same terminal window before running your code.一种解决方法是在运行代码之前在同一终端 window 中使用“提示”命令。 Like this:像这样:
prompt $$
The other workaround is to use debug console as suggested by others.另一种解决方法是按照其他人的建议使用调试控制台。
The most convenient way is to edit your user settings.json
like so最方便的方法是编辑您的用户settings.json
像这样
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "prompt $G"],
Now my integrated terminal looks like so现在我的集成终端看起来像这样
>C:/Users/guido/miniconda3/Scripts/activate
(base) >conda activate condavenv
(condavenv) >
Alternatively, you can look for Code Runner extension in the marketplace - which has the option to do exactly what you want: only the output of the code is printed and nothing else .或者,您可以在市场上寻找 Code Runner 扩展 - 它可以选择完全按照您的意愿进行操作:仅打印代码的 output,没有其他内容。
(base) E:\My Laptop\Coding\Python\Study files\Projects>
isn't from your program, it is the area to type your command in the command prompt (in VS Code). (base) E:\My Laptop\Coding\Python\Study files\Projects>
不是来自您的程序,它是在命令提示符(在 VS Code 中)中键入命令的区域。
One of the above working solution seems to have been deprecated;上述工作解决方案之一似乎已被弃用; you can adjust your vscode settings for "terminal.integrated.profiles.windows":
您可以调整"terminal.integrated.profiles.windows":
example:例子:
"Command Prompt": {
"path": ["C:\\WINDOWS\\System32\\cmd.exe"],
"args": ["/K", "prompt $G$S "], }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.