Repository navigation
Python 3.6-3.8 cannot be installed on Mac OS 11.0.1: "implicit declaration of function 'sendfile' is invalid in C99" #1737
Description
Activity
❯ pyenv install 3.6.8
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.8.tar.xz...
-> https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
Installing Python-3.6.8...
python-build: use readline from homebrew
python-build: use zlib from xcode sdkBUILD FAILED (OS X 11.0.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/bb/0bxy1cy57rb_pxdkvlyst3nh0000gn/T/python-build.20201120103846.92208
Results logged to /var/folders/bb/0bxy1cy57rb_pxdkvlyst3nh0000gn/T/python-build.20201120103846.92208.logLast 10 log lines:
struct sf_hdtr sf;
^
./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = sendfile(in, out, offset, &sbytes, &sf, flags);
^
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -DPy_BUILD_CORE -c ./Modules/_codecsmodule.c -o Modules/_codecsmodule.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -DPy_BUILD_CORE -c ./Modules/_weakref.c -o Modules/_weakref.o
2 errors generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....Reacted by Yingbo Miao, X-TRON404, rodrigoformi-zh, Andrew Vathanakamsang, alon gouldman, Aldo Solís, Suraj Kumar, ZHU, tarunama, Ze Liu and 1 moreReacted by xvno and Ze LiuI solved this issue by the method provided by this blog.
Step 1 Align command-line tools
Open Xcode-beta.app
Go to Preference > Locations
Select the right version of command-line toolsStep 2 Install python
In this case, I installed 3.8.0. If you want to install a different version, you will need to change the version in the following command.
CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.8.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)Reacted by Joe, fangqi179, 🎴, Corentin Berteaux, Eren Aktas, Frédéric Harper, xwjack, Chanhwan Choi, Matt Bornski, Jesús Vargas and 137 moreReacted by Towry Wang, AMNAALARAIMI, Joshua-Luke Bevan, Danilo Znamerovszkij, Benjamin Beuster, Talal Alamdar, come2ry, Jyotirmoy Roy, Pranjal Gupta, Aishwarya Lad and 15 moreReacted by Eren Aktas, hugoliv, Frédéric Harper, xwjack, akhut13, Jesús Vargas, Roberth, 장재영, Arnau Sangrà, vaibhav jain and 46 moreReacted by 장재영, Katerina5649, Koh Wee Lun, Clarence, Isaac R., Mat, mindynild, Petur Subev, Ainuddin Faizan, Smart World, Diptanu Sarkar and 41 moreReacted by cklimpe1, Yash Mittal and Sara Capdevila SoleReacted by Joenhle, Bryce Pedroza, Will Dembinski, Chase Jensen and Sara Capdevila SoleHit the exact error:
./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ret = sendfile(in, out, offset, &sbytes, &sf, flags);when trying to install python 3.6.12
QDH for me which worked was to turn off the check:
> CFLAGS=-Wno-implicit-function-declaration pyenv install 3.6.12 Installed Python-3.6.12 to /Users/myuser/.pyenv/versions/3.6.12Reacted by Augusto Andreoli, bbw, Sarah Abderemane, Edwin Mendez, Dale O'Brien, Francisco Rivas, Freddy Esteban, Zhaofeng, Arpit Chauhan, Max and 52 moreReacted by Damon Chen, Andy Huynh, Hector, zhuanyongxigua and AdiGabaieReacted by Jessie Beech, Arpit Chauhan, Nick Kendra, Andy Huynh, Hector, Nanci Abarca, Victor Yap, Ashvjit, Ivan Dunin, Callum Floume and 4 moreReacted by Hector, Victor Yap, Gerold Csendes, sam-thorpe, Callum Floume, Jose Augusto Paiva, zhuanyongxigua, Rahul Patil, talimentibel, AdiGabaie and 3 moreReacted by AdiGabaie and Igor Andruskiewitsch- install python 3.6.0, you can change the version
CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
In case it's useful to anyone else, here's how to do this in fish shell:
CFLAGS="-I"(brew --prefix openssl)"/include -I"(brew --prefix bzip2)"/include -I"(brew --prefix readline)"/include -I"(xcrun --show-sdk-path)"/usr/include" LDFLAGS="-L"(brew --prefix openssl)"/lib -L"(brew --prefix readline)"/lib -L"(brew --prefix zlib)"/lib -L"(brew --prefix bzip2)"/lib" pyenv install --patch 3.6.8 < (curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1 | psub)
Reacted by AMNAALARAIMI, rong.zhao, Michael Hibbs, angelina, tienhm, Ricardo, KH, Lisa Yriart, Mikel Landajuela, PA Bourdais and 8 moreReacted by Still LearningReacted by Lisa Yriart, Piotr Wierzbicki and Willard MooreThis worked for me on macOS BigSur (11.2) for Python 3.6.12:
brew install bzip2 lbzip2 lzlib openssl zlib LDFLAGS="-L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib" CFLAGS="-I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -I$(xcrun --show-sdk-path)/usr/include -Wno-implicit-function-declaration" pyenv install 3.6.12For me this bit of code only works from 3.5.3 and up. Anything older than Python 3.5.2 doesn't work on my Mac.
Reacted by Steve Moss, Kyle Keating, Andrew Meyer, Kevin Fu, Alex Pakhomov, Foster Lee, Hubert S, jepper, Sunny Singh, anaalonsocastillo and 5 moreReacted by Chris Leyva and Liam GerriorReacted by anaalonsocastillo, Chris Leyva, Mattias Arro and michalchrulReacted by michalchrulFor the people here who were able to get pyenv to install versions of python on macOS Big Sur, were you, after that, then able to get pip within that installed python to install python modules that involve compiling C/C++ code?
I can get the installs of python to complete but the pip module installer then has similar C/C++ compilation errors.
Reacted by Danny Fowler and native-apiIs there a way of fixing this without having such a massive command to install a new peenv? Like a way to patch the binary itself?
Reacted by Maxime, Fredrik Rubensson, Duc Nguyen, Hi, Frank Kelly, J. Dou and Zsolt NagyPython versions without python/cpython#21113 and its backports are incompatible with MacOS 11 and cannot be built on it.
Releases with the fix are: 3.7.8+, 3.8.4+, 3.9.0+
Any earlier versions can't be built.
Reacted by Jordan Cole, Andrey Zhukov, Finn James, Luke Robinson, Kira Mourao, Leonard Punt, Pedro Peixoto, peem-strike, Alexander Zagniotov, Lin Kao-Yuan and 35 moreReacted by QuanReacted by michalchrul, Eli Burke, Jeremy Logan and AlReacted by Qi, sribeiro, michalchrul, AIQC, Jack Lawrence-Jones and Ronnie MoncayoNote that if you are applying modifications to CFLAGS or using a patch (or indeed probably if you are just doing a straight pyenv install!), you probably will need to ensure that CONFIG_SITE is not set in your environment. So perhaps you need to do:
CONFIG_SITE= CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline
)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/l
ib" pyenv install --patch 3.8.1 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)From the blog post in this comment and the above comments, got Python 3.6.13 to build on macOS 11.3! The following homebrew packages were installed first:
brew install bzip2 openssl@1.1 readline xzCFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.13 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)Reacted by Ron Rothman, JasonGaia, Robin Bolton, Bing-Yuan, Artur Sousa, Ronie Martinez, Christian Bush, David Poznik, Chris Thomas, Saurav Chandra and 8 moreReacted by Robin Bolton, grauscher and XcarePython versions without python/cpython#21113 and its backports are incompatible with MacOS 11 and cannot be built on it.
Releases with the fix are: 3.7.8+, 3.8.4+, 3.9.0+
Any earlier versions can't be built.
Reacted by Ryan Klein, Brian Schardt, Steven Guh, Shai Cantor, Claus F. Strasburger, Paweł, Tomasz Szczęśniak-Szlagowski, Manfredi Giordano, Rainer Hind, Eli Burke and 4 more- addedby-designthe reported behavior is as intendedthe reported behavior is as intendedthird-partythe problem is in third-party softwarethe problem is in third-party softwareand removedby-designthe reported behavior is as intendedthe reported behavior is as intended
on May 6, 2021 61 remaining items
@Sangdol actually, as of this writing, users have only provided patches for 3.6.15 (the last 3.6 release) that backport MacOS 11 support.
For other version lines, you need to install a recent enough release which has official support.We ought to document such "extended support" cases in the README -- but I'm not sure where exactly users would expect to find them.
Reacted by Bruno Rezende da Costa and Andrey Otto@Sangdol no probs, sometimes is good to be optimistic hehe. The rephrased sentence is still a great advice tho'
@Sangdol actually, as of this writing, users have only provided patches for 3.6.15 (the last 3.6 release) that backport MacOS 11 support. For other version lines, you need to install a recent enough release which has official support.
We ought to document such "extended support" cases in the README -- but I'm not sure where exactly users would expect to find them.
@native-api, I added these lines of code to my .zshrc and tryied installing the version 3.6.15. It actually worked! :D
Thanks a lotI had lots of trouble installing any 3.x version except for 3.13 on Mac OS X 12.4
Monterrey.Try this, works for some, but not me:
https://stackoverflow.com/questions/71577626/issues-installing-python-3-8-10-on-macos-12-3-monterey
brew install gcc && CC=which gcc-11pyenv install 3.7.5Apparently, Apple released a particular update in OS 12+ that rendered Python < 3.13 faulty (https://developer.apple.com/forums/thread/703557, idk all the details).
I was able to install using
pyenv install 3.13but other commands likepyenv install 3.9orpyenv install 3.7.5failed.Before installing 3.13 I also reinstalled my command line tools and tried updating Xcode
https://apple.stackexchange.com/questions/93573/how-to-reinstall-xcode-command-line-tools
https://stackoverflow.com/questions/34617452/how-to-update-xcode-from-command-lineWe ought to document such "extended support" cases in the README -- but I'm not sure where exactly users would expect to find them.
FYI, we've added the corresponding section to the README since.
LDFLAGS="-L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib" CFLAGS="-I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -I$(xcrun --show-sdk-path)/usr/include -Wno-implicit-function-declaration" pyenv install 3.7.0 python-build: use openssl@1.1 from homebrew python-build: use readline from homebrew Downloading Python-3.7.0.tar.xz... -> https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz Installing Python-3.7.0... python-build: use tcl-tk from homebrew python-build: use readline from homebrew python-build: use zlib from xcode sdk BUILD FAILED (OS X 12.6 using python-build 2.3.5-2-g03a5d653) Inspect or clean up the working tree at /var/folders/hn/q_4hj7_n71g_jtk0m52snjvh0000gp/T/python-build.20221014150623.9173 Results logged to /var/folders/hn/q_4hj7_n71g_jtk0m52snjvh0000gp/T/python-build.20221014150623.9173.log Last 10 log lines: checking for --with-cxx-main=<compiler>... no checking for clang++... no configure: By default, distutils will build C++ extension modules with "clang++". If this is not intended, then set CXX on the configure command line. checking for the platform triplet based on compiler characteristics... darwin configure: error: internal configure error for the platform triplet, please file a bug report make: *** No targets specified and no makefile found. Stop.Reacted by Normanyang1@Ancientshield Did you find a solution?
macOS 12.6
I was able to install python 3.7.7 using the .pkg downloaded from the official python website.
Now, we can backport the patches to support MacOS 11+ to 3.7.0+ and 3.8.0+ if enough people need that.
But 3.6 is EOL so I don't think we're going to touch anything but the last release, 3.6.15 (which already has those patches). Interested parties can provide a PR or commission us to handle specific version(s) for them.
Reacted by bloatfanI have the same issue as @Ancientshield . Same error.
I am not able to install 3.7.3, I was able to install 3.7.13❯ pyenv install 3.6.8 python-build: use openssl@1.1 from homebrew python-build: use readline from homebrew Downloading Python-3.6.8.tar.xz... -> https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz Installing Python-3.6.8... python-build: use readline from homebrew python-build: use zlib from xcode sdk
BUILD FAILED (OS X 11.0.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/bb/0bxy1cy57rb_pxdkvlyst3nh0000gn/T/python-build.20201120103846.92208 Results logged to /var/folders/bb/0bxy1cy57rb_pxdkvlyst3nh0000gn/T/python-build.20201120103846.92208.log
Last 10 log lines: struct sf_hdtr sf; ^ ./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ret = sendfile(in, out, offset, &sbytes, &sf, flags); ^ clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -DPy_BUILD_CORE -c ./Modules/_codecsmodule.c -o Modules/_codecsmodule.o clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ethanyan/.pyenv/versions/3.6.8/include -I/usr/local/opt/openssl@1.1/include -DPy_BUILD_CORE -c ./Modules/_weakref.c -o Modules/_weakref.o 2 errors generated. make: *** [Modules/posixmodule.o] Error 1 make: *** Waiting for unfinished jobs....
Hi @EthanYan6 ,
Please let me know if you were able to fix this issue for mac M1.Hi @native-api ,
I'm still facing issues with python 3.6.8 installation on Mac M1. Please let me know if any patch is available for this. Please find the latest error -~ % CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv86 install --patch 3.6.8 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1) Error: No available formula with the name "openssl@1.0". Did you mean openssl@1.1 or openssl@3? Downloading openssl-1.1.0j.tar.gz... -> https://www.openssl.org/source/old/1.1.0/openssl-1.1.0j.tar.gz Installing openssl-1.1.0j... Installed openssl-1.1.0j to /Users/lokesh.raizada/.pyenv/versions/3.6.8 python-build: use readline from homebrew Downloading Python-3.6.8.tar.xz... -> https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz Installing Python-3.6.8... patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst patching file configure Hunk #1 succeeded at 3375 (offset -51 lines). patching file configure.ac Hunk #1 succeeded at 495 (offset -15 lines). python-build: use readline from homebrew python-build: use zlib from xcode sdk BUILD FAILED (OS X 12.6.1 using python-build 20180424) Inspect or clean up the working tree at /var/folders/41/4c6czpkx6c18sfcfj0lzjkd00000gq/T/python-build.20230208104408.53599 Results logged to /var/folders/41/4c6czpkx6c18sfcfj0lzjkd00000gq/T/python-build.20230208104408.53599.log Last 10 log lines: checking for --with-cxx-main=<compiler>... no checking for clang++... no configure: By default, distutils will build C++ extension modules with "clang++". If this is not intended, then set CXX on the configure command line. checking for the platform triplet based on compiler characteristics... darwin configure: error: internal configure error for the platform triplet, please file a bug report make: *** No targets specified and no makefile found. Stop.@StillLearning-HTTPStatus200 Only 3.6.15 has the patch to support MacOS 11+ and XCode 13.3. 3.6 is EOL so we have no plans for anything beyond that from our side.
Reacted by Still Learning and Ismael Ors@StillLearning-HTTPStatus200 Only 3.6.15 has the patch to support MacOS 11+ and XCode 13.3. 3.6 is EOL so we have no plans for anything beyond that from our side.
Thank you for the response @native-api
As I see the link has support for - 2.7.18 : MacOS 10.15+ and Apple Silicon.Is there any support/patch available for python 3.6.8 for Mac with M1 chips as well? :(
I solved it for 3.6.7, mac OS sonoma and M2 chip with this: https://dev.to/0xkoji/install-python-3-7-3-6-and-3-5-on-bigsure-with-pyenv-3ij2
I'm opening a discussion why people keep using non-last EOL micro releases without downstream patches -- because I don't quite understand,
Backport downstream patches for EOL versions to non-last releases? · pyenv · Discussion #3299
Hi,Morning:
First of all, thank you very much for thinking about and maintaining pyenv. We found problems installing pypypy3 via pyenv, but we were also able to find solutions we would like to share with you.
Cordial greetings
jianping zhang
environment
describe
`BUILD FAILED (OS X 11.0.1 using python-build 20180424)
Inspect or clean up the working tree at /tmp/python-build.20201120091233.71993
Results logged to /tmp/python-build.20201120091233.71993.log
Last 10 log lines:
./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = sendfile(in, out, offset, &sbytes, &sf, flags);
^
./Modules/posixmodule.c:10432:5: warning: code will never be executed [-Wunreachable-code]
Py_FatalError("abort() called from Python code didn't abort!");
^~~~~~~~~~~~~
1 warning and 1 error generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated`