sudo apt-get install -y make build-essential libssl1.0-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev
sudo dnf install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel
Alternative of openssl-devel:python
sudo dnf install compat-openssl10-devel --allowerasing
zypper in zlib-devel bzip2 libbz2-devel readline-devel sqlite3 sqlite3-devel libopenssl-devel xz xz-devel
brew install readline xz
NOTE: libssl-dev
is required when compiling Python, installing libssl-dev
will actually install zlib1g-dev
, which leads to uninstall and re-install Python versions (installed before installing libssl-dev
). On Redhat and derivatives the package is named openssl-devel
.git
rm -rf ~/.pyenv/versions/2.7.5
CONFIGURE_OPTS="--with-arch=i386" CFLAGS="-arch i386" LDFLAGS="-arch i386" python-build options
If you want to install a Python interpreter that's available to all users and system scripts (no pyenv), use /usr/local/
as the install path. For example:github
sudo python-build 3.3.2 /usr/local/
You can set your CFLAGS to accepted safe values to help get a little more speed.sql
CFLAGS='-O2'
If you encounter this error while installing python and your server is a VPS, the /tmp directory where python-build download and compile the packages is probably mounted as noexec. You can check with your hosting provider if whether they provide a way to bypass this protection.shell
If the answer is no, just set the $TMPDIR environment variable to wherever you have a write + execution rights. For example:xcode
export TMPDIR="$HOME/src"
Please note you'll have to do it every time you'll want to install a new version of python unless you write this command in your ~/.bashrc
.bash
If you've got something like that:less
$ pyenv install 2.7.5
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...
BUILD FAILED
Please, be sure to have "make" installed ($ sudo apt-get install make
). On Ubuntu Server, by default, it doesn't.curl
Installing Python-2.7.7...
ERROR: The Python zlib extension was not compiled. Missing the zlib?
Please consult to the Wiki page to fix the problem.
https://github.com/yyuu/pyenv/wiki/Common-build-problems
BUILD FAILED
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 2.7.7
xcode-select --install
If you experience both issues with openssl and zlib, you can specify both search paths as a compiler flag:ionic
CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib"
CFLAGS="-I$(brew --prefix openssl)/include" \ LDFLAGS="-L$(brew --prefix openssl)/lib" \ pyenv install -v 3.4.3
or (checked on RHEL6):
CFLAGS=-I/usr/include/openssl \
LDFLAGS=-L/usr/lib64 \
pyenv install -v 3.4.3
or (checked on Arch Linux):
LDFLAGS="-L/usr/lib/openssl-1.0" \ CFLAGS="-I/usr/include/openssl-1.0" \ pyenv install -v 3.4.3
CFLAGS="-I/opt/local/include/" \ LDFLAGS="-L/opt/local/lib/" \ pyenv install -v 3.4.3
On FreeBSD 10-RELEASE and 11-CURRENT, you may need to recompile security/openssl
without SSLv2 support. (See #464).
On Debian stretch (and Ubuntu bionic), libssl-dev is OpenSSL 1.1.x, but support for that was only added in Python 2.7.13, 3.5.3 and 3.6.0. To install earlier versions, you need to replace libssl-dev
with libssl1.0-dev
. This is being tracked in https://github.com/pyenv/pyenv/issues/945.
To update your python-build definitions:
If you have python-build installed as an pyenv plugin:
$ cd ~/.pyenv/plugins/python-build && git pull