skip to Main Content

I’ve been experiencing a whole of clutter in the terminal when I run programs in Python.
Example:

PS C:UsersdanheAppDataRoamingCode> & C:/Users/danhe/AppData/Local/Microsoft/WindowsApps/python3.11.exe "c:/Users/danhe/OneDrive/Desktop/Python projects/22222222.py"
Hello, world
PS C:UsersdanheAppDataRoamingCode> 

I tried using code runner to display the output but get a similar problem:

[Running] python -u "c:UsersdanheOneDriveDesktopPython projects22222222.py"
Hello, world

[Done] exited with code=0 in 0.267 seconds

I don’t know how other people got the dollar sign or nothing and I get all this crap. It’s hard to stay organized with all the clutter and has made me turn to Jupyter notebook exclusively for self-teaching.

A dozen online tutorials and many google searches and none address my problem.

2

Answers


  1. It seems like the clutter you’re seeing in the terminal when running Python scripts (You are on Windows if Im right) is related to the command prompt’s default behavior.

    You can improve the readability and organization of your terminal by changing your terminal prompt.

    The "PS" and other information at the beginning of your terminal prompt is specific to Windows PowerShell. You can customize your prompt to make it cleaner. You can do this by modifying your PowerShell profile.

    For example:

    function prompt {
        "PS $($executionContext.SessionState.Path.CurrentLocation)> "
    }
    

    Save this script in your PowerShell profile. To edit your profile, run notepad $PROFILE in PowerShell and add the function. This will change your prompt to something like PS C:YourCurrentDirectory>.

    Login or Signup to reply.
  2. If you use Code Runner, adding the following settings will give you clean results in OUTPUT:

        "code-runner.runInTerminal": false,
        "code-runner.clearPreviousOutput": true,
        "code-runner.showExecutionMessage": false,
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search