Help us understand the problem. What is going on with this article?

pyexpat が原因で pyenv install が出来ない解決方法

pyenv install 3.7.3したら下の様なエラーが発生した

現状

MacOS Mojave10.14.5を使ってpyenv 1.2.12経由でpyenv install 3.7.3したらpyexpatがビルドが出来ないエラーが発生した。

version

MacOS Mojave10.14.5
pyenv 1.2.12

エラー内容

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

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

Inspect or clean up the working tree at /var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/python-build.20190618113202.9421
Results logged to /var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/python-build.20190618113202.9421.log

Last 10 log lines:
  File "/var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/tmpmrukj_i2/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/cmdoptions.py", line 22, in <module>
  File "/var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/tmpmrukj_i2/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/utils/hashes.py", line 10, in <module>
  File "/var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/tmpmrukj_i2/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/utils/misc.py", line 21, in <module>
  File "/var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/tmpmrukj_i2/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 35, in <module>
  File "/private/var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/python-build.20190618113202.9421/Python-3.7.3/Lib/plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
  File "/private/var/folders/02/2q54w44n1010wm667_3wfx340000gn/T/python-build.20190618113202.9421/Python-3.7.3/Lib/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ModuleNotFoundError: No module named 'pyexpat'
make: *** [install] Error 1

どのバージョンのpythonをインストールしても同じエラーが発生する。

解決方法

https://github.com/pyenv/pyenv/issues/1066
こちらに記載されている方法で解決した!!!

1. コマンドラインツールをversionを変更する

https://developer.apple.com/download/more/?=command%20line%20tools
Command Line Tools for Xcode Betaのバージョンをインストール。

2. ちゃんとインストール出来ているか確認

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

上のコマンドの実行結果

package-id: com.apple.pkg.CLTools_Executables
version: 11.0.0.0.1.1559496560
volume: /
location: /
install-time: 1560831114
groups: com.apple.FindSystemFiles.pkg-group

versionが上記になっていれば正常??

3. 環境変数を設定

以下のコマンドを実行して、環境変数を設定する。

export CFLAGS="-I/usr/local/Cellar/openssl/1.0.2s/include"
export LDFLAGS="-L/usr/local/Cellar/openssl/1.0.2s/lib"

4. pyenv install 3.7.3

いつも通りにインストール出来た!!

解決方法があまり記載されていなかったので、書きました。

karon9
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした