35
23

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.

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

Last updated at Posted at 2019-06-18

#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

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

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

35
23
4

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
35
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?