LoginSignup
5
3

More than 5 years have passed since last update.

pipでモジュールがインストールできないときの対処法メモ

Last updated at Posted at 2018-05-16

pip3 installは使えるけどpip installはエラーが出て使えなかったときの一連の解決法です.

環境

MacOSX 10.13.4

方法

エラー内容はメモってなかったので忘れました.
SSLがなんとかって書いてあったはず.

対処1:opensslをHomebrewでインストール

原因はデフォルトのopensslが古かったこと.
そこでHomebrewでopensslをインストールします.

brew install openssl

これだけではエラーは何も変わりませんでした.
どうやらbrewでインストールしたopensslが参照されておらず,
もともとMacに入ってたのが優先されてしまっているらしい.

brewの方を使ってもらうようにします.

対処2:brewの方のopensslをリンクさせる

brew link openssl --force

でリンクします.

するとこんなエラーが

Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

調べると

https://qiita.com/dasisyouyu/items/c9621c29b0fe79d2b7c4
どうやらopensslへのlinkは貼れなくなったらしい

ということで,リンクさせるのはやめて,パスの設定をします.

対処3:パスの設定

vi ~/.bash_profile

でbash_profileを開きます.
開いたらiでINSERTモードにして,適当な場所に

export PATH=/usr/local/opt/openssl/bin:$PATH

と書きます.
Escでノーマルモードに戻ったら,Shift+ZZで保存して終了.

source .bash_profile

を実行して変更を適用したら,ターミナルを再起動します.

まとめ

which openssl 

でパスを調べて,/usr/bin/opensslから
/usr/local/opt/openssl/bin/opensslとなっていたら成功です.

これでpipが使えるようになりました.

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