1 Install pyenv
-
checkout pyenv
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
-
Define environment variable PYENV_ROOT
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
or Ubuntu/Fedora ~/.bashrc or Zsh: ~/.zshenv
-
Add pyenv init into shell
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then \n eval "$(pyenv init -)"\n fi' >> ~/.bashrc
-
Restart shell
$ exec "$SHELL"
-
Install build-essential and libssl-dev in Ubuntu
$ apt install build-essential libssl-dev
Recommended: make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev libreadline-dev readline-common libffi-dev
https://github.com/pyenv/pyenv/wiki/Common-build-problems
Recommended (ubuntu 16.04): zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
For Ubuntu 18.04: zlib1g-dev libbz2-dev sqlite libsqlite3-dev openssl libreadline-dev readline-common
Centos:
$ yum install openssl-devel
-
List all available python version
$ pyenv install -l
-
Install specific version of python
$ pyenv install 3.5.5 $ pyenv global 3.5.5 # set 3.5.5 as global version
2 Update pyenv
$ cd ~/.pyenv && git pull -r
3 pyenv pip error
find_packages() got an unexpected keyword argument ‘include’
https://github.com/quantopian/zipline/issues/1278
To install a particular version in my python env is:
pip install setuptools==<specific version>
or (upgrading to the latest):
pip install -U setuptools
4 Missing sqlite3 header file
CFLAGS=”-I$(xcrun –show-sdk-path)/usr/include” pyenv install -v 2.7.14