Install WSL on Windows
If not already installed, create a WSL environment on your Windows development workstation. This process is well documented by Microsoft so I'll just provide a link to their WSL pages here.
Install pyenv
By default, the WSL environment probably has the latest/greatest version of Python installed. Since we want to develop using Python 3.10, we'll accomplish this by installing pyenv
, which enables us to switch between Python versions as needed.
Install packages required by penv
At a WSL command line, run the following apt install
command:
sudo apt install -y gcc make build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev liblzma-dev
Install pyenv
Next install the pyenv
package:
curl https://pyenv.run | bash
Add pyenv to the WSL environment
Within the wsl command line, add the following lines to your .bashrc
file (I use nano):
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Either close and re-open your terminal window or use source ~/.bashrc
to reload settings.
Install Python 3.10.0 using pyenv
With pyenv installed, enter the following command to use pyenv to download and install a local installation of Python 3.10.0:
pyenv install 3.10.0
Setting Python 3.10.0
penv
can set Python 3.10.0 as the global version of python, or as the version only within a current directory:
pyenv global 3.10.0 # Set 3.10.0 as the default version of Python
pyenv local 3.10.0 # Set 3.10.0 as the version when running within the current folder