# [pyenv](https://github.com/pyenv/pyenv)
## install
```shell
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
```
add `pyenv` command into path
```shell
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
```
restart shell, then enjoiy the `pyenv`
```shell
exec "$SHELL"
```
## install python env
see all versions which are able to install
```shell
pyenv install --list
```
pick one to install
```shell
pyenv install 3.5-dev
```
success ouput
```plain
Cloning https://github.com/python/cpython...
Installing Python-3.5-dev...
Installed Python-3.5-dev to /home/ubuntu/.pyenv/versions/3.5-dev
```
## troubleshoting
### build fail
similar ouput
```plain
Installing Python-3.4.3...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/yyuu/pyenv/wiki/Common-build-problems
BUILD FAILED (Ubuntu 15.04 using python-build 20150601-11-g36c5cbf)
Inspect or clean up the working tree at /tmp/python-build.20150709085352.14078
Results logged to /tmp/python-build.20150709085352.14078.log
Last 10 log lines:
(cd /home/bjlee/.pyenv/versions/3.4.3/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 6.0.8 requires SSL/TLS
```
run below comman to fix it
```shell
sudo apt-get install libreadline-gplv2-dev
sudo apt-get install libssl-dev libsqlite3-dev libbz2-dev
```