LoginSignup
1
0

More than 1 year has passed since last update.

pipenv/pyenvでPython3.*をインストールするとBUILD FAILEDになる(macOS 11+)

Last updated at Posted at 2022-11-12

BUILD FAILED!

macOSでbrewで入れたpyenvPython 3.*をインストールしようとすると失敗する(pipenvの環境構築でpyenvでインストールしようとしても当然同じエラーが出る).

(MacBook Pro 2019, macOS 12.6, Intel Core i7)

$ brew install pyenv
...
$ pyenv install 3.7.10

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

BUILD FAILED (OS X 12.6 using python-build 1.2.27)

...

make: *** No targets specified and no makefile found.  Stop.

修正済みのPythonのバージョン

どうやらAppleがCLangの仕様を変更してCPythonと非互換になったらしく, Python 3.*については以下のマイナーアップデートでそれぞれ修正されているらしい.

Python Version
3.7 3.7.13
3.8 3.8.13
3.9 3.9.11
3.10 3.10.3

brew版pyenvはバージョン対応が遅い

そこでPython3.8.13を入れようとしてみる.

$ pyenv install 3.8.13
python-build: definition not found: 3.8.13

See all available versions with `pyenv install --list'.

If the version you need is missing, try upgrading pyenv:

  cd /Users/-/.pyenv/plugins/python-build/../.. && git pull && cd -

ぐぬぬ. 存在しないと言われてしまった. 実際, インストール可能なバージョンを表示してみると

$ pyenv install -list
...
3.8.6
3.8.7
3.9.0
3.9-dev
3.9.1
...
3.9.8
3.10.0
3.10-dev
...

見事に欲しいバージョンがインストール不可になっている. pyenvバージョンが古い場合もあるらしいのでアップデートしようとするが, 既に最新版が入ってると出てしまう.

$ brew upgrade pyenv
Warning: pyenv 1.2.18 already installed

どうやら, brew版のpyenvバージョン対応が遅いらしい.

pyenv-installerpyenvをインストールし直す

そこで, brewで入れたpyenvを一旦削除し, pyenv-installerpyenvをインストールし直してみる.

$ brew uninstall pyenv
...
$ curl https://pyenv.run | bash
$ exec $SHELL
$ pyenv update

そして上述のPython3.8.13をインストールする.

$ pyenv install 3.8.13
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.13.tar.xz...
-> https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tar.xz
Installing Python-3.8.13...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8.13 to /Users/-/.pyenv/versions/3.8.13

これでやっとインストールすることができた. pyenvの環境構築は毎回失敗している気がする.

1
0
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
0