5
3

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 3 years have passed since last update.

Homebrew + pyenvでPython 3.4.3をインストールしたかった話

Last updated at Posted at 2020-03-13

はじめに

pyenv + Python 3.4.3を構築するにあたって半日くらい費やしてしまったので、その備忘録です。

前提

  • macOS Catalina 10.15.3
  • Homebrew 2.2.10
  • fish 3.1.0
  • pyenv 1.2.16
pyenv install 3.8.1
pyenv global 3.8.1

は成功。

Python 3.4.3のインストール

同様にインストールを試みるもエラー発生。

pyenv install 3.4.3

〜〜略〜〜
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
〜〜略〜〜

失敗: OpenSSLに関するコンパイルオプションの指定

公式Wiki1によると、「コンパイルオプションを指定すると良い」とのことだが、同様エラーにより撃沈。

If you have homebrew openssl and pyenv installed, you may need to tell the compiler where the openssl package is located:

試したコマンド(※fish用です。)

set -gx CPPFLAGS "-I/usr/local/opt/openssl/include"
set -gx LDFLAGS "-L/usr/local/opt/openssl/lib" 
pyenv install 3.4.3

〜〜略〜〜
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
〜〜略〜〜

成功: HomebrewからのOpenSSLパッケージの削除

同公式Wiki1によると、「(Ubuntuでは)OpenSSLのバージョン変更により解決するかも?」とのこと。

If you're having trouble to get it to compile older python versions(<3.5) even after installing the recommended packages on ubuntu, changing the openssl lib might help:

そこで、とりあえずHomebrewに入っているOpenSSLをアンインストールしてみた。ただし、同パッケージはpyenvが依存関係にあるため、--ignore-dependenciesオプションを指定。

brew uninstall --ignore-dependencies openssl@1.1
pyenv install 3.4.3

その後、ログを眺めていると冒頭でPython 3.4.3のインストールの前にOpenSSL 1.0.2kをビルドし始めて成功の予感が。

Downloading openssl-1.0.2k.tar.gz...
-> https://pyenv.github.io/pythons/6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
Installing openssl-1.0.2k...
〜〜略〜〜
Installed Python-3.4.3 to /Users/yaumu3/.pyenv/versions/3.4.3

無事成功です。

後片付け

Python 3.4.3インストール時にインストールされたOpenSSLを削除し、HomebrewにOpenSSLを再インストールする。

rm -rf /usr/local/opt/openssl
brew reinstall openssl@1.1

さいごに

  1. HomebrewからOpenSSLのアンインストール
  2. 古いバージョンのOpenSSLをHomebrewにインストール2
  3. PATHを通す
  4. コンパイルオプションを指定してpyenv install 3.4.3

でも成功しますが、この方法が一番シンプルだと思います。

  1. pyenv/Wiki/Common build Problems 2

  2. Qiita - homebrew で openssl 1.0 がインストールできなくなっています

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?