Shivansh Sahu
Shivansh Sahu

Reputation: 19

VS Code is not running Python Programs and is showing a Powershell Advert on the Terminal and the Terminal is not showing the path

Problem

As soon as I click 'Run Python File in Terminal', it does nothing, no errors, nothing just remains idle, but if I run the same file with the python IDLE, it works, I re-installed the latest version of Python and VS Code but still the problem isn't solved. Also, the Terminal shows a Powershell advert and doesn't show the path like it usually should.

Edit: Powershell shows an advert and doesn't work properly

Powershell

The code runs properly in CMD

CMD

The VS Code extensions I use are:

  1. Bracket Pair Colorizer
  2. Code Runner
  3. Jupyter (Idk what it does but VS Code prompted me to install it for Python)
  4. Live Server
  5. Material Icon Theme
  6. Pylance (Idk what it does but VS Code prompted me to install it for Python)
  7. Python

This is the content of settings.json

{
    "editor.fontSize": 18,
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "window.zoomLevel": -1,
    "workbench.colorTheme": "Default Dark+",
    "workbench.editorAssociations": [],
    "python.languageServer": "Pylance",
    "editor.mouseWheelZoom": true,
    "code-runner.clearPreviousOutput": true,
    "code-runner.saveAllFilesBeforeRun": true,
    "code-runner.saveFileBeforeRun": true
}

Because of this problem, I ignored VS Code and installed PyCharm and I am having no issues with it.

Upvotes: 0

Views: 1541

Answers (1)

Jill Cheng
Jill Cheng

Reputation: 10372

According to the information you provided, the problem is that the powershell terminal that comes with the system cannot be used. Because VS Code is an editor, its internal powershell terminal integrates the powershell terminal from the system. However, VS Code not only supports this terminal, it also supports cmd terminal, bash and so on.

Solution: Since you can run python code in cmd terminal outside of VS Code, please use

 "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",

instead of

"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",

in "settings.json" in VS Code to switch the terminal to cmd.

Or you could use the following method, which can also switch the terminal to cmd:

enter image description here

Reference: Integrated terminal in VS Code.

Upvotes: 1

Related Questions