Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Common build problems
sudo apt-get install -y make build-essential 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
Alternative of libreadline-dev:
sudo apt install libedit-dev
- Fedora/CentOS/RHEL(aws ec2):
sudo yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel \ openssl-devel xz xz-devel libffi-devel
Alternative of openssl-devel:
sudo yum 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
When running Mojave or higher (10.14+) you will also need to install the additional SDK headers by downloading them from Apple Developers. You can also check under
/Library/Developer/CommandLineTools/Packages/ as some versions of Mac OS will have the
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
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
Removing a python version
rm -rf ~/.pyenv/versions/2.7.5
Installing a 32 bit python on 64 bit Mac OS X (this will not work on Linux)
CONFIGURE_OPTS="--with-arch=i386" CFLAGS="-arch i386" LDFLAGS="-arch i386" python-build options
Installing a system-wide Python
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:
sudo python-build 3.3.2 /usr/local/
Make your pythons a little faster
You can set your CFLAGS to accepted safe values to help get a little more speed.
Build failed - bad interpreter: Permission denied
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.
If the answer is no, just set the $TMPDIR environment variable to wherever you have a write + execution rights. For example:
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
If you've got something like that:
$ 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.
Build failed: "ERROR: The Python zlib extension was not compiled. Missing the zlib?"
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
- On Mac OS X 10.9, 10.10, 10.11 and 10.13 you may need to set the CFLAGS environment variable when installing a new version in order for configure to find the zlib headers (XCode command line tools must be installed first):
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 2.7.7
- If you installed zlib with Homebrew, you can set the CPPFLAGS environment variable:
CPPFLAGS="-I/usr/local/opt/zlib/include" pyenv install -v 3.7.0
- Alternatively, try reinstalling XCode command line tools for your OS (especially if you just upgraded your OS)
If you experience both issues with openssl and zlib, you can specify both search paths as a compiler flag:
CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib"
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
- If you have homebrew openssl and pyenv installed, you may need to tell the compiler where the openssl package is located:
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
- Alternatively, if you installed openssl with macports, use the following paths:
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/opensslwithout 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
libssl1.0-dev. This is being tracked in https://github.com/pyenv/pyenv/issues/945.
python-build: definition not found
To update your python-build definitions:
If you have python-build installed as an pyenv plugin:
$ cd ~/.pyenv/plugins/python-build && git pull