Closed4

pyenvでpythonのビルドに失敗する(MacOS / Big Sur)

homebrewで入れたpyenvでpython install 3.9.0すると途中でこける

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

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

Inspect or clean up the working tree at /var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/python-build.20210107102840.2870
Results logged to /var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/python-build.20210107102840.2870.log

Last 10 log lines:
  File "/private/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/python-build.20210107102840.2870/Python-3.9.0/Lib/ensurepip/__init__.py", line 210, in _main
    return _bootstrap(
  File "/private/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/python-build.20210107102840.2870/Python-3.9.0/Lib/ensurepip/__init__.py", line 129, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/python-build.20210107102840.2870/Python-3.9.0/Lib/ensurepip/__init__.py", line 38, in _run_pip
    return subprocess.run([sys.executable, "-c", code], check=True).returncode
  File "/private/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/python-build.20210107102840.2870/Python-3.9.0/Lib/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/private/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/python-build.20210107102840.2870/Python-3.9.0/python.exe', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/tmp9_ytvlam/setuptools-49.2.1-py3-none-any.whl\', \'/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/tmp9_ytvlam/pip-20.2.3-py2.py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/var/folders/py/ny_k2b7d2952s80nwx32nv3c0000gn/T/tmp9_ytvlam\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [install] Error 1

xcode select -- install するとよい、みたいなのをみかけるけど最新だった。
Xcodeは12.3

こちらで解決💡

https://github.com/pyenv/pyenv/issues/1219#issuecomment-727951276

LDFLAGSの環境変数を渡す

$ LDFLAGS="-L$(xcrun --show-sdk-path)/usr/lib" pyenv install 3.9.0

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
Installing Python-3.9.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.0 to /Users/ytkhs/.pyenv/versions/3.9.0
$ pyenv versions
* system (set by /Users/ytkhs/.pyenv/version)
  2.7.18
  3.9.0

$ pyenv global 3.9.0

$ python -V
Python 3.9.0

Big SurでXcode SDKの場所が変わったんだろうか?🤔

このスクラップは2021/01/07にクローズされました
ログインするとコメントできます