How to Change your Python Version within the Windows Executor

Problem

It is possible while we have a specific version of Python installed on our Windows Executor, your builds require something different instead.

 

Solution

If the version that you are looking for is not installed, you can try the following command:

 

run: choco install python --version={{python version}} --force -y  /norestart

 

If the version of python is  installed on the executor, but just needs to be referenced, you can use the following (using Python 3.9 as an example):

- run:
    
name: installed version verification
    
shell: bash
    
command: |
      py -3.9 -m venv venv39
      source ./venv39/Scripts/activate
      python --version

 

You should now be able to run the requested Python versions in your Windows Builds. 

 

Additional Notes:

An additional recommendation is using Pyenv to manage different Python runtimes.

 https://github.com/pyenv-win/pyenv-win


It can be useful useful when there are many projects requiring different Python runtime versions (e.g., Python 3.8.5 vs Python 3.9.10, etc).

Additional Resources

See information on our Windows Orb:
https://circleci.com/developer/orbs/orb/circleci/windows

Information on our Windows Executor:
https://circleci.com/docs/using-windows/https://docs.gradle.org/current/userguide/troubleshooting.html

 

Pyenv Windows Version usage:
https://github.com/pyenv-win/pyenv-win#usage

If you are still experiencing problems after trying this, for further questions or suggestions for your particular use-case, please contact CircleCI Support.

Was this article helpful?
1 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.