0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pip install が使えずにTLS/SSLエラーがでたとき

0
Posted at

実行環境

・Ubuntu 22.04.4 LTS
・Python 3.10.12

エラー詳細

前に venv で作った仮想環境(env)に入り flask を install しようとした

bash
source env/bin/activate
pip install flask

すると下のエラーが出てきた

WARNING: pip is configured with locations that require TLS/SSL, 
however the ssl module in Python is not available. WARNING: 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/flask/

要するに python の SSL モジュールが使えなくなっている

原因

まず今入っているPythonを確認

bash
which python3

下のように出たらそれが原因

/usr/local/bin/python3

/usr/bin/python3と出るのが理想。もしそうやって出ていても同じエラーが出るならピンチかも

対処法

結局 python を入れ直すのが一番早い

bash
sudo apt update
sudo apt install python3 python3-venv python3-pip openssl libssl-dev -y

python を入れ直して下を実行してエラーが出ていなければ最高

bash
/usr/bin/python3 -m ssl

仮想環境も作り直す

bash
rm -rf env
/usr/bin/python3 -m venv env
source env/bin/activate

もう一回確認

bash
python -m ssl

エラーが出なければpipが使える

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?