0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Macのpyenvでpythonをインストールできない

Last updated at Posted at 2025-02-13

概要

poetry install xx.xx.xxでpythonをインストールしようとすると
install: Modules/_blake2.cpython-312-darwin.so: No such file or directoryが返されてしまった。
特殊ですが、同じ人もいるかもしれないので解決した時の方法を残しておきます。(といってもほぼ海外記事の要約ですが)

環境

・ Mac(M3)
・arm用とx_86用のHomebrewのパラレル構成でパッケージ(pyenv含む)を管理

arm版: opt/homebrew
x_86版: /usr/local/homebrew

症状

下記のようにpyenvでpythonのインストールを行うと

pyenv install 3.12.9

下記エラーが発生

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

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

Inspect or clean up the working tree at /var/folders/zy/rlqcx37d3wn804wr99j9yn540000gp/T/python-build.20250213171040.80924
Results logged to /var/folders/zy/rlqcx37d3wn804wr99j9yn540000gp/T/python-build.20250213171040.80924.log

Last 10 log lines:
/usr/bin/install -c -m 755 Modules/zlib.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/zlib.cpython-312-darwin.so
/usr/bin/install -c -m 755 Modules/_dbm.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so
/usr/bin/install -c -m 755 Modules/readline.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/readline.cpython-312-darwin.so
/usr/bin/install -c -m 755 Modules/_md5.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/_md5.cpython-312-darwin.so
/usr/bin/install -c -m 755 Modules/_sha1.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/_sha1.cpython-312-darwin.so
/usr/bin/install -c -m 755 Modules/_sha2.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/_sha2.cpython-312-darwin.so
/usr/bin/install -c -m 755 Modules/_sha3.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/_sha3.cpython-312-darwin.so
/usr/bin/install -c -m 755 Modules/_blake2.cpython-312-darwin.so /Users/taguchi/.pyenv_arm/versions/3.12.9/lib/python3.12/lib-dynload/_blake2.cpython-312-darwin.so
install: Modules/_blake2.cpython-312-darwin.so: No such file or directory
make: *** [sharedinstall] Error 71

対策

結論から言うと、x86環境のlibb2を削除する。 または、 arm環境にlibb2を追加する。 ことで解決するらしい。
pyenvのissueに解決法を載せてくれていた。

I did install x64 arch brew for gaming, to /usr/local, and then arm64 arch brew to /opt
I uninstalled libb2 from the x64 brew as prescribed, and this resolved my issue!

原因

x_86とarm64の2つの環境を作っていることが原因だった。

下記ドキュメントにある通り、
コンパイラの検索パスにx86環境(/usr/local/homebrew)もarm64環境(opt/homebrew)も含まれてしまうので、あるライブラリがx86のHomebrewだけにインストールされリンクされていた場合、たとえarm64用にコンパイルしていても、コンパイラはx_86のライブラリを検出してしまう。
とのこと。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?