LoginSignup
7
7

More than 3 years have passed since last update.

Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")でハマったときの話

Last updated at Posted at 2020-09-25

はじめに

Webスクレイピングの練習のために
サンプルコードを入手してスクレイピングを試したところ
例外が発生してドハマりしたので事象と解決方法をメモする

事象

【Python】スクレイピングで株価データを取得するを参考にして
スクリプトを実行したところ↓↓のエラーが発生して処理が進められなかった。
PCも工場出荷状態に戻した直後だったので結構焦る。

スクリプト実行結果のエラーメッセージ
requests.exceptions.SSLError: HTTPSConnectionPool(host='***.co.jp', 
port=443): Max retries exceeded with url: / (Caused by SSLError("Can't 
connect to HTTPS URL because the SSL module is not available."))

環境

anaconda 1.9.12
python 3.8.3

解決方法

参考:https://stackoverflow.com/questions/54135206/requests-caused-by-sslerrorcant-connect-to-https-url-because-the-ssl-module

環境変数に以下のパスを入れたら直った。
:環境変数
%USERPROFILE%\Anaconda3
%USERPROFILE%\Anaconda3\scripts
%USERPROFILE%\Anaconda3\Library\bin

具体的にはこんな感じ。
スクリーンショット 2020-09-25 105532.png

おわりに

今さら振り返ると、python実行環境はanaconda3なのに、vscode上からpythonを起動したから
anacondaでインストールしたパッケージが参照されなかったのかなぁ…なんて思った。
ともかく、問題解決してよかった。

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