0
0

More than 3 years have passed since last update.

Mac OSX 10.15.5にpyenvでPython2.7.xを入れる

Posted at

Mac OSX 10.14.x以降は同じかもしれませんが、
OSを10.15.5にUpgradeしたらpyenvで2.7.x系のインストールができなくなってしまったので
メモとして残します。

Python 2.7.13のインストール

pyenvでPython 2.7.13のインストールを行うと、以下のエラーが表示される。

% pyenv install 2.7.13
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.13.tar.xz...
-> https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
Installing Python-2.7.13...
patching file ./Lib/site.py
python-build: use readline from homebrew
ERROR: The Python zlib extension was not compiled. Missing the zlib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.15.5 using python-build 1.2.8)

Last 10 log lines:
rm -f /Users/nier/.pyenv/versions/2.7.13/share/man/man1/python.1
(cd /Users/nier/.pyenv/versions/2.7.13/share/man/man1; ln -s python2.1 python.1)
if test "xno" != "xno"  ; then \
        case no in \
            upgrade) ensurepip="--upgrade" ;; \
            install|*) ensurepip="" ;; \
        esac; \
         ./python.exe -E -m ensurepip \
            $ensurepip --root=/ ; \
    fi
%  

解決策

私の場合は、Xcode, CommandLine Toolはインストール済みでしたので、以下のコマンドで上手く入りました。

CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 2.7.13

ちなみに、Xcodeをインストールしていない方は、Xcodeをインストール後にCommandLine Toolをインストールします。

xcode-select —install

なお、エラーにも記載されていますが、上記でも解決しない場合は公式ドキュメントをみるのがいいです。。
https://github.com/pyenv/pyenv/wiki/Common-build-problems

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