Pyenv, Python installation failure: OpenSSL development header is not installed
Asked Answered
G

2

7

I've been unable to use Pyenv to install Python on macOS (10.13.6) and have exhausted advice about common build problems.

pyenv-doctor reports: OpenSSL development header is not installed. Reinstallation of OpenSSL, as suggested in various related GitHub issues has not worked, not have various flag settings, eg (in various combinations):

export CFLAGS="-I$(brew --prefix openssl)/include"
export CPPFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig/"
export PATH="/usr/local/opt/[email protected]/bin:$PATH"

(Tried these in command line put as well.)

(Tried both OpenSSL 1.02p and 1.1, via Homebrew)

Tried

brew install readline xz

and

$ CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.6.6

and

$ CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib" pyenv install 3.6.6

and

xcode-select --install
(or via downloadable command line tools installer for reinstallation)

No luck.

brew link --force openssl

is disallowed (error message says to use flags).

Also tried:

$(brew --prefix)/opt/openssl/bin/openssl

and tried the OpenSSL/macOS advice here:

https://solitum.net/openssl-os-x-el-capitan-and-brew/

$PATH shows:

/usr/local/opt/openssl/bin:/Users/tc/google-cloud-sdk/bin:/Users/tc/Code/git/flutter/bin:/usr/local/sbin:/usr/local/heroku/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/tc/google-cloud-sdk/bin:/Users/tc/Code/git/flutter/bin:/usr/local/sbin:/usr/local/heroku/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/tc/google-cloud-sdk/bin:/Users/tc/.nvm/versions/node/v8.11.3/bin:/Users/tomclaburn/Code/git/flutter/bin:/usr/local/sbin:/usr/local/heroku/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local/mongodb/bin:/usr/local/opt/openssl/bin/openssl:/usr/local/mongodb/bin:/usr/local/mongodb/bin

and .bash_profile contains:

if [ -d "${PYENV_ROOT}" ]; then
   export PATH="${PYENV_ROOT}/bin:${PATH}"
   eval "$(pyenv init -)"
   #eval "$(pyenv virtualenv-init -)"
fi

I suspect there's a missing/incorrect path or link but I've been unable to determine what it might be. Any advice would be welcome.

Pyenv error output: BUILD FAILED (OS X 10.13.6 using python-build 20180424)

...

Last 10 log lines:

checking size of long... 0
checking size of long long... 0
checking size of void *... 0
checking size of short... 0
checking size of float... 0
checking size of double... 0
checking size of fpos_t... 0
checking size of size_t... configure: error: in `/var/folders/jb/h01vxbqs6z93h_238q61d48h0000gn/T/python-build.20180819081705.3009/Python-3.6.6':
configure: error: cannot compute sizeof (size_t)

pyenv-doctor error output:

checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking for rl_gnu_readline_p in -lreadline... yes
checking for readline/readline.h... no
checking for SSL_library_init in -lssl... yes
checking how to run the C preprocessor... clang -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... no
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... yes
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
configure: error: OpenSSL development header is not installed.
Goth answered 19/8, 2018 at 16:32 Comment(5)
I’m confused. What are you trying to do? Just install python?Calix
I'm trying to have multiple versions of Python installed, using Pyenv to manage them. A single version of Python isn't a problem.Goth
I use two versions of python on my machine. I had to use virtual environments to get them to work properly. I use python 3.6 and 2,7 and they work fine and play together well. I use the Anaconda distribution of python though so I didn't need pyenv.Calix
There are many internet sites that will help you create virtual environments on a mac. Its a painless task using Anaconda and pretty easy the other way too. Afew sites are: gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3Calix
sourabhbajaj.com/mac-setup/Python/virtualenv.html ; and exponential.io/blog/2015/02/10/… These 2 references also explain why it's best to use VE's...Calix
C
15

If this is the same issue as me, it's because there's headers in your path that shouldn't be there. Run brew doctor and you would see it complain. To fix it you can do:

mkdir /tmp/includes
brew doctor 2>&1 | grep "/usr/local/include" | awk '{$1=$1;print}' | xargs -I _ mv _ /tmp/includes
Cryobiology answered 23/8, 2018 at 9:18 Comment(1)
Highly underrated answer. I've been having this problem for a year.Makings
F
4

After applying Kit's answer; I had to do the following to overcome the fact that I also installed openssl with homebrew:

CFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv doctor

That got me working. Also found this reference useful for common build problems.

Formidable answered 25/10, 2018 at 15:45 Comment(1)
@4thSpace - You are correct, the pyenv doctor option is no longer available. The reference in my answer provides additional options if you are continuing to have an issue. I've since updated my OS to macOS 10.15 and no longer have the issue.Formidable

© 2022 - 2024 — McMap. All rights reserved.