0

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.

3
  • Please note that Azure != Azure DevOps. You might want to change the title of your post. Commented Feb 3, 2025 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? Commented Feb 4, 2025 at 4:32
  • Hi, can you please check the answer and use UsePythonVersion@0 task in your pipeline? Commented Feb 27, 2025 at 7:38

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

correct version

version check:

version check

2 Comments

Good catch - I think the documentation of the UsePythonVersion@0 task needs to be updated, specially the part mentioning that "Downloading python versions is not supported on self-hosted agents".
Hi @RuiJarimba, yes, I remember I tested this task last year, and at that time, on a self-hosted agent, this task did not support automatic downloading of the required Python version. I was also surprised yesterday, and the documentation needs to be updated.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.