I have a self-hosted agent that has Python3.9.18 installed which comes as part of RHEL 9 Image. Everytime I run the pipeline I get an error.
##[error]Version spec 3.9 for architecture x64 did not match any version in Agent.ToolsDirectory.
Versions in /home/<user>/myagent/_work/_tool:
<BLANK>
I have created the folder structure as well
/myagent/_work/_tool/Python/3.9/x64/<tool files>
and x64.complete
but still no success it doesn't find anything underneath "Agent.ToolsDirectory
"
environment variable has been set.
echo $Agent.ToolsDirectory
/home/<user>/myagent/_work/_tool
Could you recommend some options to consider?
What needs to be done for the tool files? What are these files?
Tried options :
I tried by keeping unzipped python 3.9.18 tar files but no success
I tried creating a simlink to point _tool
to /usr/bin/python
where my base python is installed.
Referred this link and tried setting venv but dnf was not able find and install the package.
Whenever I tried installing the python to this new _tool
directory it just says python already installed.
I am trying to use this task UsePythonVersion@0
.
I tested in my self-hosted agent. I can reproduce the issue when I use the version 3.9
in the path.
In the official document How can I configure a self-hosted agent to use this task?, it mentions that
The version number should follow the format of
1.2.3.
As a complete and concrete example, here is how a completed download of Python 3.11.4 for x64 would look in the tool cache:
$AGENT_TOOLSDIRECTORY/
Python/
3.11.4/
x64/
{tool files}
x64.complete
So, you should change the /myagent/_work/_tool/Python/3.9/x64/<tool files>
to /myagent/_work/_tool/Python/3.9.18/x64/<tool files>
.
Update:
You can download the python package version you need in the python-versions releases page or python-versions tags page and unzip it as the {tool files}.
For example:
The x64.complete
file is not in the x64
folder.
You can also use the following yaml to check the python files in the Microsoft hosted agent.
pool:
vmImage: ubuntu-latest
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
architecture: 'x64'
- bash: tree $(Agent.ToolsDirectory)/Python/3.9.19
- task: CopyFiles@2
inputs:
SourceFolder: '$(Agent.ToolsDirectory)/Python/3.9.19'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
The published artifact content: