UPDATE:
Now that I tried the solution from the answers to try
python -m ensurepip
python -m pip install --upgrade pip
pip install tox poetry
I realize that the self-hosted windows agent apparently did not even have the python. I followed this instruction from azure: use python version
where they say something like the direction structure.
$AGENT_TOOLSDIRECTORY/
Python/
3.6.4/
x64/
{tool files}
x64.complete
what is confusing is the definition of {tool files}
Initially, I downloaded the python executable from the website This gave me an .exe file. So I created a folder structure in
c:/agent/_work/_tool/
as below
$AGENT_TOOLSDIRECTORY/
Python/
3.9.9/
x64/
python_3.9.9-amd64.exe
x64.complete
Since this is definitely not the right way to do it. I am not sure what is the definition of {tool files}. I am currently stuck on how to correctly install python on the self-hosted windows agent.
Then I tried to use a venv to create folder architecture as advised in
Link. Since the demo is for Linux, the venv installation turned out to be different. There was no bin folder created. And instead a pyvenv.cfg
file was created. This venv configuration referred to path where the python was originally installed. The folder structure was as follows when I did this.
$AGENT_TOOLSDIRECTORY/
Python/
3.6.4/
x64/
Include/
Libs/
Scripts/
pyvenv.cfg
x64.complete
This made the powershell task that was discussed below to fail as follows. From the cfg
file the powershell tried to look for the python in users' folder istead of the
_tool` folder.
I am lost here, any help is appreciated. Thanks a lot.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
EARLIER ISSUE:
I am trying to create a Pipeline for my python project using self-hosted Windows agent. Here is the link to my repository where you can find the azure yml files. https://GringottsFinance@dev.azure.com/GringottsFinance/NLNETSalaryCalculator.Py/_git/NLNETSalaryCalculator.Py
For the tox related steps, I created this template
parameters:
PythonVersion: ''
ToxEnvironment: ''
steps:
- checkout : self
fetchDepth: 1
- task: UsePythonVersion@0
displayName: Use Python Version ${{ parameters.PythonVersion }}
inputs:
versionSpec: ${{ parameters.PythonVersion }}
condition: succeeded()
- powershell: pip install tox poetry
displayName: Install Tox and Poetry
condition: succeeded()
- powershell: tox -r -e ${{ parameters.ToxEnvironment }}
displayName: Run the give Tox Environment
condition: succeeded()
My problem is that even though the python version 3.9.9 is successfully installed in the agent, the PowerShell doesn't seem to find the pip.
- I have tried adding the path to environment variables.
- I have also restarted the agent several times after adding the variables.
None of the solutions seem to work. Any help is appreciated.