LoginSignup
7
8

More than 3 years have passed since last update.

macOS Big Surにアップデート後、pyenvを使用したpythonインストールが失敗するようになった問題の対処法

Last updated at Posted at 2021-02-21

・MacOS Big Sur 11.2.1
・xcode.app: 12.4
・pyenv: 1.2.22

こんなエラー

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

Inspect or clean up the working tree at /var/folders/7t/s4sxvwqd5pqcy3jh_n5vfpjr0000gn/T/python-build.20210221175447.57865
Results logged to /var/folders/7t/s4sxvwqd5pqcy3jh_n5vfpjr0000gn/T/python-build.20210221175447.57865.log

Last 10 log lines:
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize)                 __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
                                                     ^
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include   -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include   -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/~/.pyenv/versions/3.8.2/include  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/~/.pyenv/versions/3.8.2/include   -DPy_BUILD_CORE_BUILTIN  -DPy_BUILD_CORE_BUILTIN -I./Include/internal -c ./Modules/posixmodule.c -o Modules/posixmodule.o
./Modules/posixmodule.c:9197: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.

App StoreからXcodeをインストールする(時間掛かるカモ)

image.png

アクティブデベロッパディレクトリに、先ほどインストールしたXcodeアプリケーションのDeveloperディレクトリを指定する

$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

xcodebuildを実行する。

sudo xcodebuild -runFirstLaunch

↓とりあえずエンターキー押す。

You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.

Hit the Return key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'

↓agree と入力してエンター

.
..
...
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel] agree

You can view the license agreements in Xcode's About Box, or at /Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf

Install Started
1%.........20.........40.........60.........80........Install Succeeded

Install Succeededが表示されれば完了です

python3.8.5インストール

$ pyenv install 3.8.5

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.8.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8.5 to /Users/~/.pyenv/versions/3.8.5

python 3.9.0もインストールできた。

python3.8.2インストール

python3.8.2 および それより下のバージョンについては相変わらずエラーが出てしまう状態。
issuesより、下記コマンドで3.8.2はインストールできました。
ただ、修正対応も頑張ってくれているっぽい。

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

python3.7.8インストール

3.7系は上記コマンドでも相変わらずエラー。。。(上記patchはMacOS v11サポート用だから、v3.7はまた別?)
3.7.8はpyenv installで普通にインストールできたので、3.7系も大丈夫かな・・・。(3.7.Xによってはエラーになるかもしれない)

$ pyenv install 3.7.8
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.7.8...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.7.8 to /Users/~/.pyenv/versions/3.7.8 
7
8
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
7
8