Search code examples
pycharmpytestpython-3.10

'py.test' is not recognized as the name of a cmdlet, function, script file, or operable program


Hi I am trying to run my tests using "py.test" command in the Pycharm terminal but every time is am getting this error message:

py.test : The term 'py.test' 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

  • py.test
  •   + CategoryInfo          : ObjectNotFound: (py.test:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

Solution

  • First anwser:

    Check if python -m pytest or just pytest works for you. If it does - maybe you have installed pytest in a different env/global env. That can make pytest library unavailable/unreachable in your environment. If the command does not work for you - make sure you have installed pytest library: pip install pytest

    Second answer:

    Try to change the default shell inside Pycharm to use CMD (I think you are using PowerShell?), then restart pycharm. Make sure you are using CMD as your default shell inside the pycharm terminal. enter image description here