4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mac OS X 10.15.x pyenv Python インストールできない場合

Last updated at Posted at 2019-12-21

pyenv でのpython インストールに失敗してしまう場合

こんな風に
Catalina のベータ版で起きやすいようです

% pyenv install 3.8.0
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.0.tar.xz...
-> https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
Installing Python-3.8.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 10.15.3 using python-build 1.2.15-9-gac246e16)

Inspect or clean up the working tree at /var/folders/xm/g1kzbj4504vc7jy43b8jls480000gn/T/python-build.20191222050242.8852
Results logged to /var/folders/xm/g1kzbj4504vc7jy43b8jls480000gn/T/python-build.20191222050242.8852.log

Last 10 log lines:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:540:6: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:200:34: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
        defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1))
                                        ^
220 warnings and 10 errors generated.
make: *** [Parser/parser.o] Error 1
220 warnings and 10 errors generated.
make: *** [Parser/bitset.o] Error 1
220 warnings and 10 errors generated.
make: *** [Parser/metagrammar.o] Error 1

pyenv を再インストール

% mv .pyenv .pyenv_old
% git clone git://github.com/yyuu/pyenv.git ~/.pyenv
Cloning into '/Users/xxx/.pyenv'...
remote: Enumerating objects: 26, done.
remote: Counting objects: 100% (26/26), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 17572 (delta 9), reused 9 (delta 3), pack-reused 17546
Receiving objects: 100% (17572/17572), 3.44 MiB | 3.90 MiB/s, done.
Resolving deltas: 100% (11936/11936), done.

% echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
% echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
% echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
% source .bash_profile 

環境整備

% brew install readline xz openssl zlib

インストール実行

% env SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" CFLAGS="-I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" CPPFLAGS="-I/usr/local/opt/zlib/include" LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib" pyenv install 3.8.0
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.0.tar.xz...
-> https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
Installing Python-3.8.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8.0 to /Users/xxx/.pyenv/versions/3.8.0

% pyenv global 3.8.0

初回のインストール時にこれが必要っぽい

SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"

CFLAGS="-I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" 

CPPFLAGS="-I/usr/local/opt/zlib/include"

LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib"
4
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?