Koki's personal blog

Koki's personal blog

Another fine, responsive site template by HTML5 UP.

Installing pyenv, and Python by pyenv on WSL (Ubuntu 18.04 LTS)

This article explains how to install pyenv, and Python by pyenv on WSL (Ubuntu 18.04 LTS).

Koki

1-Minute Read

This article explains how to install pyenv, and Python by pyenv on WSL (Ubuntu 18.04 LTS).

The following lists are the table of contents about this article.

Target audience

  • Those who want to install pyenv and Python on WSL.

Environment

  • WSL (Ubuntu 18.04 LTS)

Preconditions

  • Already installed git.

Installing pyenv

Execution the following commands.

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
exec "$SHELL"

Then reboot WSL for applying the setting.
Installation of pyenv is now complete.

Installing Python by pyenv

Installing libraries that need for installing Python

Execution the following command.

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev

Installing Python

Execution the following command, then setting Python version that will use.
In this case, installing Python 3.8.2.

pyenv install 3.8.2
pyenv global 3.8.2

Reference articles

Recent Posts

Categories