What to do in my case when pyenv install is not possible after upgrading to macOS Big Sur

What I tried & the error I encountered

  1. An environment where multiple versions can be installed and switched with pyenv on mac was working (python 3.6 3.8 series)
  2. Upgraded to macOS Big sir
  3. 3.6 3.8 When I try to install another version of the series with `pyenv install`, the installation does not complete with the following error.
BUILD FAILED ...
...
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);
...

Many people seemed to have encountered this, and the solution was discussed in pyenv's GitHub issue. While referring to this page, make a note of the operation when it was solved in my environment.

environment

Solved operation

Reinstall xcode tools
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Reinstall 2 packages with brew
brew reinstall zlib bzip2
Add the following to ~/.zshrc
export PATH="$HOME/.pyenv/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

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"

I reopened the terminal for the changes I made to take effect. At this point, version 3.8 series could be installed with `pyenv install` in my environment.

Version 3.6 series installation

I tried `` `pyenv install 3.6.12``` asking if this would include 3.6 series, but I got the first error. Then, when I typed the following command (one line) according to the Reference Page, the installation of version 3.6.0 was successful.

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)

Then, changing only the version number and typing the following command succeeded in installing version 3.6.12.

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.12 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

References

https://github.com/pyenv/pyenv/issues/1737

Recommended Posts

What to do in my case when pyenv install is not possible after upgrading to macOS Big Sur
What to do if pyenv is not enabled (zsh)
What to do when is not in the sudoers file.This incident will be reported.
What to do when Japanese is not displayed on matplotlib
What to do when a Missing artifact occurs in a jar that is not defined in pom.xml
What to do when the value type is ambiguous in Python?
NameError: global name'dot_parser' is not defined and what to do when it comes up in python
What to do when the result downloaded via scrapy is in English
What to do if pyenv install does not proceed with an error
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do when a warning message is displayed in pip list
What to do if CERTIFICATE_VERIFY_FAILED occurs when nltk.download () is done on macOS pyhon
What to do when "TypeError: data type not understood" appears in python's numpy.zeros
What to do if abort is displayed when inputting camera video in OpenCV
What to do when the graph does not appear in jupyter (ipython) notebook
Notes on what to do if "macOS 11 or later required!" Appears in Big Sur or pyarrow2.0.0 cannot be installed
[EC2] What to do when selenium is stuck and processing does not proceed
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if the progress bar is not displayed in tqdm of python
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do when Python starts up in Anaconda does not come out unexpectedly
What to do if Python does not switch from the System version in pyenv
[openpyxl] What to do when IllegalCharacterError appears in pandas.DataFrame.to_excel
curl: (60) What to do when Issuer certificate is invalid.
What to do when there is no response due to Proxy setting in Python web scraping
When Pydev is not displayed even after adding Pydev5.2 to Eclipse (2016/8/30)
What to do when PyCharm font is strange or garbled
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
What to do when "Invalid HTTP_HOST header" appears in Django
What to do if pip install mysqlclient fails on MacOS
[Beginner] What to do when "[Errno 2] File b'test.csv' does not exist: b'test.csv" is displayed when reading pandas csv
[virtualbox] What to do when [Could not retrieve mirrorlist] appears when yum update is performed on CentOS7
What to do if the user name is changed and the pyenv library path does not pass
What to do when the jupyterlab extension settings are not reflected
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ())
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
[Python] What to do when PEP8 is violated in the process of importing from the directory added to sys.path
What to do if you get the error RuntimeError: Python is not installed as a framework when trying to use matplitlib and pylab in Python 3.3
What to do when Ubuntu crashes
What to do with Magics install
[Memorandum] What to do when a warning appears after executing pip list
What to do if there is a decimal in python json .dumps
[Python] What to do when an error related to SSL authentication is returned
Notes on what to do when matplotlib scatter () / scatter3d () does not work
After all, what should I use to do type comparisons in Python?