Skip to content

Can't compile any versions of python on El Capitan #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Feiox opened this issue Oct 4, 2015 · 27 comments
Closed

Can't compile any versions of python on El Capitan #451

Feiox opened this issue Oct 4, 2015 · 27 comments

Comments

@Feiox
Copy link

Feiox commented Oct 4, 2015

I'm also having this problem with ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib or ERROR: The Python zlib extension was not compiled. Missing the zlib?

I am running a clean install of El Capitan 10.11 instead of an upgrade. I have tried all the solutions below:

but the same error ~~~~~ T_T

Here is the full error msg:

Downloading Python-2.7.10.tgz...
-> https://yyuu.github.io/pythons/eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Installing Python-2.7.10...
patching file ./Lib/site.py
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 (OS X 10.11 using python-build 20150818)

Inspect or clean up the working tree at /var/folders/hl/zb01qhxx29g1yx0p869qyt9r0000gn/T/python-build.20151004100320.23104
Results logged to /var/folders/hl/zb01qhxx29g1yx0p869qyt9r0000gn/T/python-build.20151004100320.23104.log

Last 10 log lines:
rm -f /Users/Feiox/.pyenv/versions/2.7.10/share/man/man1/python.1
(cd /Users/Feiox/.pyenv/versions/2.7.10/share/man/man1; ln -s python2.1 python.1)
if test "xno" != "xno"  ; then \
        case no in \
            upgrade) ensurepip="--upgrade" ;; \
            install|*) ensurepip="" ;; \
        esac; \
         ./python.exe -E -m ensurepip \
            $ensurepip --root=/ ; \
    fi

install py 2.7.10, err msg:

Downloading Python-2.7.10.tgz...
-> https://yyuu.github.io/pythons/eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Installing Python-2.7.10...
patching file ./Lib/site.py
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 (OS X 10.11 using python-build 20150818)

Inspect or clean up the working tree at /var/folders/hl/zb01qhxx29g1yx0p869qyt9r0000gn/T/python-build.20151004100320.23104
Results logged to /var/folders/hl/zb01qhxx29g1yx0p869qyt9r0000gn/T/python-build.20151004100320.23104.log

Last 10 log lines:
rm -f /Users/Feiox/.pyenv/versions/2.7.10/share/man/man1/python.1
(cd /Users/Feiox/.pyenv/versions/2.7.10/share/man/man1; ln -s python2.1 python.1)
if test "xno" != "xno"  ; then \
        case no in \
            upgrade) ensurepip="--upgrade" ;; \
            install|*) ensurepip="" ;; \
        esac; \
         ./python.exe -E -m ensurepip \
            $ensurepip --root=/ ; \
    fi
@yyuu
Copy link
Contributor

yyuu commented Oct 4, 2015

I'm still using Yosemite. Probably you don't have OpenSSL headers in /usr/include.

This isn't intrinsic fix but reinstalling pyenv from latest github repo would help since it tries to use brew's openssl otherwise build it by itself.

@Feiox
Copy link
Author

Feiox commented Oct 4, 2015

@yyuu OpenSSL and zlib has been installed from brew.
I also try to install pyenv from latest github repo, but the same error msg ---> T_T

P.S. Did Apple's new security policy cause the problem? Would you choose to upgrade?

@thomasjo
Copy link
Contributor

thomasjo commented Oct 4, 2015

I just installed Python 2.7.10 on El Capitan (15A284) without any problems. This is definitely an environment problem, and not a problem with pyenv.


➜  ~  pyenv install 2.7.10
Downloading Python-2.7.10.tgz...
-> https://yyuu.github.io/pythons/eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Installing Python-2.7.10...
patching file ./Lib/site.py
Installed Python-2.7.10 to /Users/thomasjo/.pyenv/versions/2.7.10

➜  ~  pyenv --version
pyenv 20150913-14-gd462e15
➜  ~  brew info openssl
openssl: stable 1.0.2d (bottled)
OpenSSL SSL/TLS cryptography library
https://openssl.org/

This formula is keg-only.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

/usr/local/Cellar/openssl/1.0.2d_1 (464 files, 17M)
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/openssl.rb
...

@Feiox
Copy link
Author

Feiox commented Oct 4, 2015

@thomasjo I am running a clean install of El Capitan instead of an upgrade, so do you?
I saw some people in other issues that had the same problem. It should not be a case that exist only on my mac.
I try to compile install python and python3 from homebrew and official source package, then everything is normal. T_T Where else may be wrong?

@thomasjo
Copy link
Contributor

thomasjo commented Oct 4, 2015

@Feiox Yep, clean install. Only thing I can think of that might affect this is that I have Anaconda installed, and set up as a system-level python (e.g. python global system anaconda3-2.3.0).

@ccqpein
Copy link

ccqpein commented Oct 4, 2015

I have the same issues, and I use El Capitan too.

Even I install the zlip by brew, the problem is same.
I use

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

And it doesn't work either:

zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

BUILD FAILED (OS X 10.11 using python-build 20150818)

What can I do?

@ccqpein
Copy link

ccqpein commented Oct 4, 2015

Well, I succeed install with the #448 solution:

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

@Feiox
Copy link
Author

Feiox commented Oct 5, 2015

@ccqpein @yyuu I tried to reinstall the system again, then #448 solution makes my mac normal.
Why do I use this solution the last time it invalid? (◜◔。◔◝)

THX ~

@Feiox Feiox closed this as completed Oct 5, 2015
@shuaiey
Copy link

shuaiey commented Oct 27, 2015

Okay...I browsed throughout the Internet....Finally I it's the x-code tool problem.
on your terminal,
xcode-select --install
then,
pyenv install 3.5.0

That's solved my problem.
May this can help you.

@nguyenchiencong
Copy link

👍

@arcseldon
Copy link

El Capitan is like the "gift" that keeps on giving... @312024196 thank you, your solution worked a charm.

@shuaiey
Copy link

shuaiey commented Nov 21, 2015

@arcseldon Glad to help you :>

@shixudongleo
Copy link

xcode-select --install

solve my problem.

@woolf-wen
Copy link

@ccqpein, ur solution solve my problem

@ssbarnea
Copy link
Contributor

xcode-select --install solved the problem for me but I would find it more useful if pyenv would detect this itself.

@hervenivon
Copy link

Problem is still here, xcode-select --install solved it too for me.

@jshin49
Copy link

jshin49 commented Feb 21, 2017

For zlib, i had the same problem

This worked for me after installing zlib with brew

CFLAGS="-I/usr/local/opt/zlib/include"
LDFLAGS="-L/usr/local/opt/zlib/lib"
pyenv install -v 3.4.5

@thetylerwolf
Copy link

thetylerwolf commented May 2, 2017

I'm running OS X Sierra and the above didn't help for me. Found this solution here: https://medium.com/@pimterry/setting-up-pyenv-on-os-x-with-homebrew-56c7541fd331
and it did work.


CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \
pyenv install -v 3.6.0

@hshinde
Copy link

hshinde commented Oct 29, 2017

I was facing the problem with Python installation through all other mediums, but this is the only method worked for me.
xcode-select --install
then,
pyenv install 3.6.0a1

Thanks @echoyangyang

@xijieqjx
Copy link

macos 10.13.2
xcode-select --install is success
thanks

@GusGA
Copy link

GusGA commented Feb 4, 2018

I know, it a close issue but today Feb/4/18.
xcode-select --install do the trick

@tdibacco
Copy link

ditto, worked for me.
macOS 10.13.3
xcode-select --install

@jalevin
Copy link

jalevin commented Apr 19, 2018

Besides pyenv I also could not install ruby versions via rbenv. At this point I started looking at the system. I'd recently upgraded and used the migration assistant to move to a new machine.

  1. go to Applications and run Xcode. I had additional packages install
  2. run brew doctor. if any files in /usr/local/include show up you have 2 options. Either rename the directory to something else like include_old or remove the offending entries. I chose the first.

sudo mv /usr/local/include /usr/local/include_old
sudo mkdir /usr/local/include
sudo chown $YOU_USERNAME:admin /usr/local/include

afterward, I was able to install ruby and python versions

@paustin01
Copy link

xcode-select --install worked for me on High Sierra as well.

@0x3333
Copy link

0x3333 commented Oct 9, 2018

On Mojave:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

@ghost
Copy link

ghost commented Oct 10, 2018

@ccqpein

It is work!!
Thank you very much for your help

Error Msg

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.6.tar.xz...
-> https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
Installing Python-3.6.6...
python-build: use readline from homebrew

BUILD FAILED (OS X 10.14 using python-build 20180424)

Solved Command

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

Result Msg

Installed Python-3.6.6 to /Users/leejongyoung/.pyenv/versions/3.6.6

@joshfriend
Copy link
Member

Zlib not being found on mojave is a separate issue: #1219

@pyenv pyenv locked as resolved and limited conversation to collaborators Oct 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests