Skip to content

Instantly share code, notes, and snippets.

@iomoath
Forked from nareshganesan/ubuntu-18.04-pipenv.bash
Last active June 27, 2023 12:00
Show Gist options
  • Save iomoath/10417a055bfd6b66f522815a97d288d4 to your computer and use it in GitHub Desktop.
Save iomoath/10417a055bfd6b66f522815a97d288d4 to your computer and use it in GitHub Desktop.
Ubuntu 18.04 install python3 with pip and pyenv - for multiple python versions
# install dependencies
sudo apt install -y make build-essential \
python3 python-pip libpq-dev python3-dev 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
# pyenv for installing different python versions
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
# export pyenv path for python environments
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
OR
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
eval "$(pyenv init -)"
# install pipenv
sudo -H pip install -U pipenv
pip install --user pipenv
# list versions available
pyenv install --list
# list only 3.6 3.7 3.8
pyenv install --list | grep " 3\.[678]"
# installed versions
pyenv versions
# install specific version
pyenv install 3.7.6
# use specifiv version
pyenv global 3.7.6
# uninstall specific version
pyenv uninstall 3.7.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment