Since the environment was built on Ubuntu 18.04, I will leave it as a work memo. Use pyenv to install Python 3.8.
Ubuntu 18.04.3 LTS
$ sudo apt install git
Clone pyenv from github.
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
Set the path to an environment variable. For Ubuntu, write it in .bashrc instead of .bash_profile. [reference] https://github.com/pyenv/pyenv#basic-github-checkout
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
Set pyenv to start when the shell starts.
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
Shell reload & install confirmation.
$ exec "$SHELL"
$ pyenv --version
pyenv 1.2.15-2-g22c02022
Install the packages needed to build Python. [reference] https://github.com/pyenv/pyenv/wiki#suggested-build-environment
$ sudo apt-get update; sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Install Python 3.8.0 (wait patiently as it will take some time)
$ pyenv install 3.8.0
Installation confirmation
$ pyenv versions
* system
3.8.0
Python 3.8 is not enabled just by installing with pyenv, so specify the version explicitly.
$ mkdir -p ~/sample/py38
$ cd ~/sample/py38
$ pyenv local 3.8.0
Python3.8 is enabled under the local (below the py38 directory in the above example). (Same for pip command)
$ python --version
Python 3.8.0
$ pip --versoin
pip 19.2.3
$ pip install pipenv
$ pipenv --version
pipenv, version 2018.11.26
If you specify PIPENV_VENV_IN_PROJECT = true
in the environment variable, the venv directory will be created directly under the project. Since it is easy to link with vscode, set it to true here.
$ mkdir pipenvdemo
$ cd pipenvdemo
$ export PIPENV_VENV_IN_PROJECT=true
$ pipenv --python 3
Recommended Posts