08.21.2019
Install Python 3 using pyenv on Ubuntu
There are many ways to install python 3 into your server. Today, I will show you how to install python 3 using pyenv
I will instll python 3.7 into my Ubuntu 18.04
First we need to install some dependencies
sudo apt-get install -y build-essential libbz2-dev libssl-dev
libreadline-dev libsqlite3-dev tk-dev
sudo apt-get install -y libpng-dev libfreetype6-dev
Next, run installer script
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
Add init to your .profile or .bashrc. I will add into my .bashrc
vim ~/.bashrc
go to the end and add below content
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Restart your bash shell
exec bash
Now we are ready to install python 3
pyenv install 3.7.0
Make virtualenv so that you can change in future
pyenv virtualenv 3.6.0 general
Now active as global
pyenv global general
If you got some problem while installing, please follow this stackoverflow post to solve it
Hope this help
Happy coding.