简体   繁体   English

如何摆脱在 Visual Studio 代码终端中打印的不必要路径?

[英]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.

相关问题 如何摆脱 ttk 打印表格中的 ]、[ 和 ' 符号 - How can I get rid of the ], [ and ' signs in a printed table in ttk 我怎样才能摆脱烦人的“import pdb; pdb.set_trace()”关于 Visual Studio Code Intellisense 的自动完成建议 - How can I get rid of annoying “import pdb; pdb.set_trace()” autocomplete suggestion on Visual Studio Code Intellisense 运行包含两个while循环的此函数时,如何解决不必要的打印语句被打印的问题? - How can I fix unnecessary print statements from being printed while i run this function containing two while loops? 如何在 Visual Studio Code 的“输出”部分而不是“终端”部分从用户那里获取输入 - How can you get input from user in 'Output' section instead of 'Terminal' section in Visual Studio Code 如何摆脱以 0 结尾的浮点数不必要的点符号 - How do I get rid of unnecessary dot symbol for float ending with 0 如何删除有关 Visual Studio Code 中不必要分号的警告? - How to remove warning about Unnecessary semicolon in Visual Studio Code? Visual Studio 代码终端 - Visual Studio Code Terminal 如何在 Visual Studio 代码中使用整个终端? - How to use the whole terminal in visual studio code? 如何在可视代码终端中激活我的 virtualenv? - How can I activate my virtualenv in visual code terminal? Visual Studio Code 的解释器路径列表中的“python”是什么? 我可以删除它吗? - What is "python" in the list of interpreter paths in Visual Studio Code? And can I remove it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM