[PYTHON] Dealing with import tk, matplotlib, etc. from the state where TSL / SSL is not available

I can't pip install

I couldn't do it because I hadn't installed the library since the os was updated. TSL / SSL seems to be a problem. It seems that pyenv can not keep up with the update when I check it The following error details

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

I tried all the measures, but I will list the ones that have been solved. Note that pyenv will be deleted, so you can't restore it unless you make a note of the version you were using.

$ 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] ....

.. .. .. This fixed the TSL / SSL error. Reinstalling python is a hassle

Cannot import tk (matolotlib)

Also, a problem occurred.

I can't import tk. I can't use matplotlib. I was in trouble. It seems that there is no _Tkinter module

$ brew reinstall tcl-tk

I don't think this is the solution. https://ameblo.jp/oyasai10/entry-12526487609.htmlの通りにやったら解決した.

$ pyenv uninstall 3.6.6
https://www.activestate.com/products/tcl/tcl-tk-modules/
Here, active-Download tcl
For Mac, install it and the installer will be in the trash.
Very easy

This solved the problem around tk. All you have to do is reinstall.

$ 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
>>

Finished.

Recommended Posts

Dealing with import tk, matplotlib, etc. from the state where TSL / SSL is not available
How to return to the command from the state where you can not enter interactive mode with python of git bash