LoginSignup
1
2

More than 1 year has passed since last update.

macOS Monterey (バージョン12.1) Python3.8.0がinstallできなかったときの対処法

Last updated at Posted at 2022-01-08

macOS バージョン12にて、下記記事を参考にPython3.8.0をinstallしようとした際にエラーが発生

エラー内容

% pyenv install 3.8.0

//省略
 error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);

試したこと
https://github.com/pyenv/pyenv/issues/1643

上記のgithub issuesを読むと、homebrewからこのエラーのパッチが出てるとのことなので、参考にターミナルで以下のコマンドを入力

pyenv 3.8.0のインストール

% 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)

pyenv 3.8.3のインストール

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

pyenv version コマンドでpyenvの3.8.0と3.8.3がインストールできているのを確認

pyenv global 3.8.0でバージョン切り替えを行い、ターミナルを再起動

python -Vでバージョン確認

% python -V
Python 3.8.0

無事Python3.8.0のinstall成功

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2