LoginSignup
0
0

More than 1 year has passed since last update.

M1 Mac、MontereyでPythonインストールするとreadline warning/SSL Errorが起きる場合の対処法

Posted at

MontereyだとPythonを標準でインストールしなくなりました。
で、Pythonを使う場合、インストールする必要があるんですが、インストールした時にwarningやらエラーでハマったのでそれのメモ。
ちなみに、python2.xはサポート切れているので、基本的には3.xを入れるべきかと思います。

まず、インストールをぐぐりながら続けていくとこういうエラーが出ることがあります。

pyenv install 3.10.4
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.4.tar.xz...
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
 
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems

readline/sslがはいってないとかそんなエラーです。
入れてあるのに探せていない。パスかな?と思いきや問題はもっと根本的な部分でした。

症状としてはこちらと一緒。
M1 Macからは、ターミナルの情報をみるのプロパティ?を開くと、Rossetaを使用して開くというチェックがあります。
これは、Intel系にてterminalを使うかという切り替えになるわけですが。

これのチェックを入れて、brewやpyenvをいれたのか?いれてないのか?が大きい鍵です。

このリンク先にあるように、
Intel系で攻めるのか、M1系で攻めるのかをあらかじめ決めておく必要があります。

こちらでは、Intel系で攻めて対処した時のクイックメモを記載。

1. terminalにRossetaを使用して開くのチェックを入れる

2. brew/pyenvをインストールする

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install pyenv

これにより、/usr/local/bin/pyenvやら、/usr/local/bin/brewなどでインストールされます。

rossetaを使用して開くにチェックを入れない場合は、/opt/homebrew/bin/brewとかにインストールされるわけです。

3. .zshrc/.zprofileを変更

.zshrc
eval "$(pyenv init -)"
.zprofile
eval "$(pyenv init --path)"

とすると、インストールはすんなりできます。

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

M1版はリンク先を参考のこと。

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