skip to Main Content

I got a awkward situation when I found that I am able to run my python codes in VS Code but when I try to open python in cmd/powershell prompt: I get the following:

enter image description here

`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
  •   + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException`
    
    

Could someone throw some light on this?
Thanks.

I tried to run python from WindowPowerShell…failed. Searched the python installation folder in the drive.

Even the paths in VS Code-powershell is same as in the WindowsPowerShell, it shows two different responses.

2

Answers


  1. This is very likely an environment PATH issue. VSC has a separate set of pseudo environment variables that track things like the path to your python executable, and it will prompt you to select it if it does not find it by itself. Check your PATH settings and see if the python path is present, if not you should add it. Don’t forget to close and reopen terminals for PATH changes to take effect.

    Login or Signup to reply.
  2. In VSCode, you can manually select the python interpreter for coding. VSCode is just a code editor, it does not have its own terminal, it still uses cmd or powershell.

    However, when you use cmd directly, you need to manually activate the python interpreter or virtual environment. You need to check if the environment variable PYTHONPATH in your PC is set correctly.

    If you’re using virtual environment(Recommended method), you could set the activate script in the Scripts directory of your virtual environment:

    .venvScriptsactivate
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search