Following is the code in my yml file.
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
addToPath: true
architecture: 'x64'
I am using DevOps on self-hosted runner installed on windows 10. Getting following error.
There is python-3.12.5-amd64.exe in C:\agent_work_tool\Python\3.12.5\x64 directory.
Refer to this doc: UsePythonVersion@0 - Use Python version v0 task
To setup the Python files in self-hosted agent, you need to follow the directory structure in _tool folder:
$AGENT_TOOLSDIRECTORY/
Python/
{version number}/
{platform}/
{tool files}
{platform}.complete
If the python folder only contains .exe
file, the configuration is not valid.
You can refer to the following steps to configure the Python files to use UsePythonVersion@0 Task.
Step1: Download the required Python version package in Github: Python-versions
In your case, you have downloaded the correct package(contain python-3.12.5-amd64.exe).
Step2: We need to manually execute the python-3.12.5-amd64.exe. It will generate all configuration files.
Path: C:\Python312
or C:\Users\(Your logged in User)\AppData\Local\Programs\Python\Python312
For example:
Step3: We need copy all files in Python312 folder and paste them to the path C:\agent\_work\_tool\Python\3.12.5\x64
Step4: We need to create an empty file: x64.complete
at the same path of x64 folder.
For example:
Here is the full directory structure:
$AGENT_TOOLSDIRECTORY/
Python/
3.12.5/
x64/
{tool files}
x64.complete
Finally, you can use the Use Python version task in Azure Pipeline to set the correct version.
YAML sample:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.12.5'
addToPath: true
architecture: 'x64'
Result: