While trying to install Python 3.7.3 in my local environment to test running Selenium on AWS Lambda, I encountered the error mentioned in the title.
(Python 3.7.3 was the only version with good compatibility for running Selenium…)
error: implicit declaration of function ‘sendfile’ is invalid in C99
For reference, here’s the full error message:
My environment is as follows:
- macOS Big Sur version 11.7.4
- pyenv: stable 2.3.31
To get straight to the solution, I was able to successfully install Python 3.7.3 by running 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.7.3 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch?full_index=1)
Here’s the output of the command:
I referenced the following articles:
- https://qiita.com/hisa_shim/items/abb4936f1f676fe6a7b8
- https://qiita.com/w_omit/items/0cc5f85490317bb8524b
I think I tried to do the same thing 2-3 years ago and got stuck at the same point, so I’m documenting it here so I won’t forget next time.