0

I'm trying to create a Python file and run the code

print ('hello there')

using Visual Studio Code IDE. However when I run this code, the terminal screen shows:

PS D:\Learning Python>  & 'C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\ADMIN\.vscode\extensions\ms-python.python-2022.8.0\pythonFiles\lib\python\debugpy\launcher' '64817' '--' 'd:\Learning 
Python\learn_python.py'
Hello there

Could you please explain why is it showing the path of the extension and the exe? And how to make it shorter to

PS D:\Learning Python>" (the folder stored python file
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Yen Do Hai
  • 11
  • 2
  • the problem here looks like you saved your python file in the wrong directory – Blackgaurd Jun 19 '22 at 03:07
  • where to save python file in correct directory bro? I save .py file in D directory and .exe app in C directory which is default when I installed VSC and Python – Yen Do Hai Jun 19 '22 at 03:24
  • 1
    It's just showing you the command it executed to run your script. It's not a problem. – Tim Roberts Jun 19 '22 at 03:56
  • Does this answer your question? [How to hide file paths when running Python scripts in VS Code?](https://stackoverflow.com/questions/61176552/how-to-hide-file-paths-when-running-python-scripts-in-vs-code) – Gino Mempin Jun 19 '22 at 06:02
  • that is make sure the debugger can be called no matter what the current directory of the terminal is. If you don't want to debug (slower) use another run option `Run without debugger` – rioV8 Jun 19 '22 at 10:09

1 Answers1

0

Terribly sorry. this is how python extensions work. Because the VS Code terminal integrates the powershell or cmd terminal from the computer, it need to specify the Python path to use and the path to execute the script for.

If you don't like it, you can install the Code Runner extension. Once installed, the execute code icon in the upper right corner of VS Code will have three options.

enter image description here

Select Run Code, the code result will be output in the OUTPUT window (only the result, no extra lines).

Select Run Python File, and the code results are output in the TERMINAL window as before.

The third Debug Python File is used as debug code.

For better use, it is recommended to add the following code to your settings.json file after installing the Code Runner extension:

    "code-runner.clearPreviousOutput": true,
    "code-runner.showExecutionMessage": false,
JialeDu
  • 6,021
  • 2
  • 5
  • 24