Run Python script on Azure DevOps with Classic UI - Stack Overflow

admin2025-04-16  2

I need to run a Python script in an Azure Pipeline, for this I was thinking of using Python script with inline code, previously I needed to install the packages, so far so good.

The problem is that I can't use or install Python, when I can install it (in the self hosted agent), the python or pip command is not available. Has anyone experienced this? I can't even use UsePython extension.

I need to run a Python script in an Azure Pipeline, for this I was thinking of using Python script with inline code, previously I needed to install the packages, so far so good.

The problem is that I can't use or install Python, when I can install it (in the self hosted agent), the python or pip command is not available. Has anyone experienced this? I can't even use UsePython extension.

Share Improve this question edited Feb 4 at 1:03 Bruno Silva asked Feb 3 at 20:32 Bruno SilvaBruno Silva 611 silver badge10 bronze badges 3
  • Please note that Azure != Azure DevOps. You might want to change the title of your post. – Rui Jarimba Commented Feb 3 at 22:00
  • Hi, can you explain more about " I can't even use UsePython extension." Do you mean using the UsePythonVersion@0 task in the pipeline? If it is, is there any error messages when you use it or screenshots you can share to better check the issue? – Miao Tian Commented Feb 4 at 4:32
  • Hi, can you please check the answer and use UsePythonVersion@0 task in your pipeline? – Miao Tian Commented Feb 27 at 7:38
Add a comment  | 

2 Answers 2

Reset to default 0

Have you considered using Microsoft-hosted agents? Python and pip are already included.

You can then select one of the pre-installed versions of Python using the UsePythonVersion@0 task.

I tested the UsePythonVersion@0 task in my self-hosted agent, it will download the correct version I specified on the agent.

  - task: UsePythonVersion@0
    inputs:
      versionSpec: '3.12.1' 
      architecture: 'x64' 
  - script: |
      python --version

version check:

转载请注明原文地址:http://www.anycun.com/QandA/1744751145a87097.html