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.
- 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-MSFT Commented Feb 4 at 4:32
- Hi, can you please check the answer and use UsePythonVersion@0 task in your pipeline? – Miao Tian-MSFT Commented Feb 27 at 7:38
2 Answers
Reset to default 0Have 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: