1

Im trying to run a python script in an Azure pipeline, but it doesnt seem to be working. It keeps telling me 'python' is not recognized as an internal or external command, operable program or batch file. I have installed python and added it to the path, when I type python in the command line on the VM it works: enter image description here

But when I try to run the following command line task in the pipeline, it fails:

- task: CmdLine@2
  inputs:
    script: 'python ./tools/setPythonClientVersion.py $(Build.BuildNumber)'
  displayName: Set Client Version

I get the following error:

enter image description here

Any idea as to why this is happening?

1 Answer 1

1

I encountered a similar issues and solved it by adding the python interpreter argument to the yaml. Something like this:

- task: PythonScript@0
  displayName: Set Client Version
  inputs:
    scriptSource: inline
    script: |
     # add your script here
    pythonInterpreter: 'c:/python/python.exe'
Sign up to request clarification or add additional context in comments.

2 Comments

were you using the CmdLine@2 task or were you using a different task? When I add the argument i get the following error message: Unexpected value 'pythonInterpreter'
You are correct, it was a different task, I'll add the code above and see if it helps resolve your problem. Apologises, I misremembered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.