LoginSignup
0
0

More than 3 years have passed since last update.

TSL/SSLがavailableでない状態からの import tk, matplotlib等ができないまでの対処

Last updated at Posted at 2020-01-19

pip install ができない

osのアップデートがされてから,ライブラリのインストールをやっていなかったのでやろうとするとできなかった.
TSL/SSLが問題らしい.調べるとどうもpyenvがアップデートについていけて無い模様
以下エラー内容

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting numpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

策を一通り試したが,解決したものを載せる.
pyenvを削除するので,使っていたバージョンをメモしておく等しないと復元できないので注意

$ pyenv uninstall 3.6.6 (your version)
$ which python
/Users/[user name]/.pyenv/shims/python
$ rm -rf /Users/[user name]/.pyenv
$ sudo brew uninstall pyenv
$ brew install pyenv
$ pyenv install 3.6.6
$ pip install [library] [library] ....

...これでTSL/SSLのエラーは治った.pythonの再インストールは面倒

import tk(matolotlib)ができない

また,問題発生.

import tkができない.matplotlibが使えない.困った.
_Tkinter moduleが無いらしい

$ brew reinstall tcl-tk

これで解決と思いきやだめ.
https://ameblo.jp/oyasai10/entry-12526487609.htmlの通りにやったら解決した.

$ pyenv uninstall 3.6.6
https://www.activestate.com/products/tcl/tcl-tk-modules/
ここで,active-tclをダウンロード
Macの場合は,インストールしインストーラーがゴミ箱に入ったらOK
非常に楽

これでtk周りは解決した.
後は再インストールしていくだけ.

$ pyenv install 3.6.6
$ pyenv versions
*system
3.6.6
$ pyenv global 3.6.6
$ pyenv local 3.6.6
$ pyenv versions
system
*3.6.6
$ pip install matplotlib
$ python
>> import matplotlib
>>

終了.

0
0
2

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