Hi tarun k
As we discussed in private message,
To Check if Python is Installed in the Container, you can try the below commands in PowerShell inside the container:
- python --version
- pip --version
- where.exe python or where python
Your Linux container is using yum install -y to set up Python and related packages in a layered, declarative way. To mirror that same simplicity and reliability in your Windows Server Core container, we’ll emulate it using a PowerShell-based install for Python.
# Install Python 3.11 and pip
RUN Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.11.4/python-3.11.4-amd64.exe" -OutFile "python-installer.exe" ; `
Start-Process -Wait -FilePath "python-installer.exe" -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' ; `
Remove-Item "python-installer.exe"
# Verify Python and pip
RUN python --version
RUN pip --version
Place this docker file before the WORKDIR /azp section.
Alternatively, you can try the below steps.
- In your Dockerfile, you already have this line:
COPY install_build_tools/* ./ - I suggest you create
install_python.ps1"insideinstall_build_tools/" - Add this script in
install_python.ps1param ( [string]$AUSER, [string]$APASS ) Write-Host "Installing Python 3.12..." $pythonInstaller = "python-3.12.2-amd64.exe" Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.12.2/$pythonInstaller" -OutFile $pythonInstaller Start-Process -FilePath .\$pythonInstaller -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1" -Wait Remove-Item -Force $pythonInstaller Write-Host "✅ Python installation complete" python --version - Now add the below line in the docker file below the #Install Visual Studio Build Tools:
# Install Python RUN powershell -ExecutionPolicy Bypass -File install_python.ps1 $AUSER $env:AUSER $APASS $env:APASS
Hope this helps!
Please Let me know if you have any queries.