References:
- https://realpython.com/intro-to-pyenv/#working-with-multiple-environments
- https://www.liquidweb.com/kb/how-to-install-pyenv-on-ubuntu-18-04/
- https://github.com/pyenv/pyenv
Use below commands to install pyenv
$ 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 libffi-dev liblzma-dev python-openssl
$ curl https://pyenv.run | bash
After installation is complete add below lines to the end of ~/.bashrc to configure your shell's environment for Pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
Close and open a new terminal to take effect of the updated ~/.bashrc and then install python 3.8.10 using below command
$ pyenv install 3.8.10
Once you have pyenv installed it should automatically activate python 3.8.10 (using the .python-version file) as soon as you open project directory in terminal
If you choose not to install the pyenv then make sure that your existing python version is set to 3.8.10 before proceeding to create the venv in the following step
Check python version using the below command
$ python -V
Python 3.8.10
$ python -m venv venv --prompt bi-rss-extractor
$ source venv/bin/activate
$ pip install -r requirements.txt
You can deactivate the venv once you want to move out of this project dir using the command
$ deactivate