pythonvisual-studio-codevscode-code-runner

VScode Extension Code Runner not working/error (python) when I run program


When I installed the code runner extension and I can't run the python program this error popped up:

Image

Copyright © Microsoft Corporation. All rights reserved. 
Try the new cross-platform PowerShell https://aka.ms/pscore6 
Warning: PowerShell detected that you might be using a screen-reader and has disabled PSReadLine for compatibility purposes. 
If you want to re-enable it, run 'Import - Module PSReadLine'. 
PS C:\Users\Admin\OneDrive\Máy tính\py projects python -u " C\Users\ Admin\OneDrive\Máy tính\py project\test.py " python : The term 'python' is not recognized as the name of a cmdlet , function ,script file ,or operable program. Check the spelling of the name ,or if a path was included ,verify that the path is correct and try again. 
At line :1 char :1 
+ python -u " C:\Users\Admin\OneDrive\Máy tính\py project\test.py "  ' ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotException
+ FullyQualifiedErrorId : CommandNotFoundException

When I turned off the extension the code run normally, but when I turned on the error pop up. Thank you for reading my problem! ( •̀ ω •́ )✧


Solution

  • What means "turn off the extension its working normal". According to the error report, this should be a problem with your Python environment variable setting. Have you tried the way named "Run Python File"? This is a function in extension pylance.

    By the way, You should have installed the python extension.

    enter image description here

    updates:

    enter image description here

    You can use this option to run your python file. This is the file running option officially provided by Microsoft.