Skip to content

Instantly share code, notes, and snippets.

@jmvrbanac
Last active February 16, 2023 09:29
Show Gist options
  • Star 51 You must be signed in to star a gist
  • Fork 21 You must be signed in to fork a gist
  • Save jmvrbanac/8793985 to your computer and use it in GitHub Desktop.
Save jmvrbanac/8793985 to your computer and use it in GitHub Desktop.
Install pyenv on Ubuntu
#!/bin/bash
sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl
sudo pip install virtualenvwrapper
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'pyenv virtualenvwrapper' >> ~/.bashrc
exec $SHELL
@robomotic
Copy link

Hmm it doesn't seem to work for me on, when I try to launch pyenv virtualenv I get a "no such command virtualenv".

@LionessAlana
Copy link

Very helpful script, worked perfectly! Thanks!

@minchen57
Copy link

Hmm it doesn't seem to work for me on, when I try to launch pyenv virtualenv I get a "no such command virtualenv".

Try add the following
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

@marcofavorito
Copy link

@im-alexandre
Copy link

Really thanks!!!!!!!!

@RAbraham
Copy link

RAbraham commented Jun 15, 2020

In Ubuntu 20.04, it's now python3-pip and the command sudo pip install virtualenvwrapper becomes sudo pip3 install virtualenvwrapper

@BernardLeclerc
Copy link

I am using Ubuntu 20.10 and I had to install python-is-python3 to obtain a proper installation.

sudo apt-get install python-is-python3

Otherwise, the procedure worked like a charm.

Thanks!!

@ReshuKumari
Copy link

You can also follow this to install pyenv https://reshukumari120.medium.com/installing-pyenv-in-ubuntu-967fd05bf959 Thanks.

@neosergio
Copy link

Thanks @BernardLeclerc, your suggestion works for me as well for Ubuntu 21.10

@ashrafuzzaman
Copy link

Instead of,

echo 'pyenv virtualenvwrapper' >> ~/.bashrc

Use

echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

@styk-tv
Copy link

styk-tv commented Apr 12, 2022

Adding virtualenv plugin installation in addition. Thanks for the gist
Updated version: https://gist.github.com/styk-tv/b160cd2e4a54472ba04a17f11b7faca5

@zmunro
Copy link

zmunro commented Jun 7, 2022

How is pyenv not an apt-get package I can install with one command??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment