Reputation: 19
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
The code runs properly in CMD
The VS Code extensions I use are:
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
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:
Reference: Integrated terminal in VS Code.
Upvotes: 1