I have a self-hosted Azure DevOps Pipeline build agent and would like to download and install Python from the Github repository if it is not already available in the agent tools directory.
The official documentation for the Azure DevOps pipeline task UsePythonVersion@0 states about the input 'githubToken':
githubToken: # string. Optional. Use when disableDownloadFromRegistry = false GitHub token for GitHub Actions python registry.
I am not familiar with GitHub actions and am confused regarding what I should provide for the githubToken input. It is a PAT? Or does it refer to the GITHUB_TOKEN? Where shall I obtain such token so that my pipeline can successfully download Python from GitHub.
The error I experience at the moment is:
##[error]Failed to download Python from the Github Actions python registry (https://github.com/actions/python-versions). Error: Error: unable to get local issuer certificate
This task will fail if no Python versions are found in Agent.ToolsDirectory.
To use this task with self-hosted agent, you could follow this link.
First, you could download the appropriate installer from Python.org
I downloaded python-3.7.9-amd64.exe for test.
Then you could run command line (CMD run as administrator) to install the python python-3.7.9-amd64.exe /quiet InstallAllUsers=0 TargetDir={agentinstallPath\_work\_tool}\Python\3.7.9\x64 Include_launcher=0

Remember to switch to the folder which contains python-3.7.9-amd64.exe

At last, you need to create an empty {platform}.complete file.
$AGENT_TOOLSDIRECTORY/
Python/
{version number}/
{platform}/
{tool files}
{platform}.complete

After restarting the self-hosted agent, pipeline run well.
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.7.9'
inputs:
versionSpec: 3.7.9
[error]Failed to download Python from the Github Actions python registry
this error might appear also in case if the file was downloaded, but there were errors with installing python from downloaded ".zip" archive. Thus it is necessary to provide full log and not only name of the error.
Back to your other question. To get a token open "Github.com":
or try this url: https://github.com/settings/tokens?type=beta
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With