LoginSignup
9
5

"cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_'"の原因

Last updated at Posted at 2023-06-23

発生したこと

いつもの環境とは別の環境で開発を進めようと、
・git clone して、
・python -m pip install -r requirements.txt して、
・uvicorn main:app --reload して、
プログラム(FastAPI)を起動したら、

"cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_'"

が発生。

直近のurllib3のバージョン変更によるものですが、日本語の記事が全然なかったので共有です。

原因

原因は「urllib3」が、つい2週間前(2023年6月前半)にLatestが、
1系から2系になったことによるものらしい。

 ⇒botocoreが、urllib3 2.0をまだサポートしていない 。
  ※すぐに、botocore側も追従されるかもですね。

image.png

対処

なので、
$ pip uninstall urllib3
で現在のurllib3を削除、

$ python -m pip install 'urllib3<2'
で、1.26.16をインストールすることで解消。

どうやら、Lambda上で動かすときにも引っかかるとかいう記事があるので、
引っかかった場合、この変を見てみるとよいかも。

※環境は、WSL2のubuntu 20.04、Pythonは3.9

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