0

I'm currently running 3.10.4 globally, but I need different versions of Python for different projects. I can run pyenv install 3.9.7 with no problem, but I can't run pyenv install 3.7.0 without it failing. Here's my output when I run 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 readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/python-build.20220505141749.63960
Results logged to /var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/python-build.20220505141749.63960.log

Last 10 log lines:
                                                     ^
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include   -I/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include   -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration   -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/alex.mcgraw/.pyenv/versions/3.7.0/include -I/usr/local/opt/zlib/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/alex.mcgraw/.pyenv/versions/3.7.0/include -I/usr/local/opt/zlib/include   -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include   -I/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include   -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration   -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/alex.mcgraw/.pyenv/versions/3.7.0/include -I/usr/local/opt/zlib/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/alex.mcgraw/.pyenv/versions/3.7.0/include -I/usr/local/opt/zlib/include   -c ./Modules/errnomodule.c -o Modules/errnomodule.o
./Modules/posixmodule.c:8401:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);
              ^
1 error generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.

After searching stack overflow for this error, people recommended running this

pyenv install 3.7.0 --patch < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch)

After running that, I get this error.

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...
patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
patching file configure
Hunk #1 succeeded at 3371 (offset -55 lines).
patching file configure.ac
Hunk #1 succeeded at 490 (offset -20 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/python-build.20220505141012.50818
Results logged to /var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/python-build.20220505141012.50818.log

Last 10 log lines:
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/python-build.20220505141012.50818/Python-3.7.0/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
  File "/var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/tmpwhslh57t/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/__init__.py", line 20, in <module>
  File "/var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/tmpwhslh57t/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/urllib3/__init__.py", line 8, in <module>
  File "/var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/tmpwhslh57t/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/urllib3/connectionpool.py", line 7, in <module>
  File "/private/var/folders/mj/9sc31q_j7vn89b1z8lq3lhq40000gn/T/python-build.20220505141012.50818/Python-3.7.0/Lib/socket.py", line 49, in <module>
    import _socket
ModuleNotFoundError: No module named '_socket'
make: *** [install] Error 1

I've tried uninstalling and reinstalling xcode and adding

eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"

to my ~/.zshrc, but nothing seems to work.

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • 1
    Edited tags. The fact that you are using Homebrew seems definitely relevant; "version control" is not a related concept. That does **not** mean "controlling which version of Python [etc.] is installed in the environment"; it means "using a specific kind of software to manage prior versions of the code for archival, integration etc. purposes". – Karl Knechtel May 05 '22 at 19:30
  • @KarlKnechtel Thank you for that. Didn't think about it. – Alex McGraw May 05 '22 at 19:38

0 Answers0