chakokuのブログ(rev4)

テック・コミック・ごくまれにチャリ

メモ: url parse error を回避するためurllib3をupgrade

urlがパーズエラーと怒られるので回避

requests.exceptions.InvalidURL: Failed to parse: https://192.168.10.216/api/v1/controllers/aiseg
>>>
$ sudo python -m pip install --upgrade urllib3
Collecting urllib3
  Downloading urllib3-1.26.3-py2.py3-none-any.whl (137 kB)
     |????????????????????????????????| 137 kB 7.0 MB/s
Installing collected packages: urllib3
  Attempting uninstall: urllib3
    Found existing installation: urllib3 1.25.8
    Not uninstalling urllib3 at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'urllib3'. No files were found to uninstall.
Successfully installed urllib3-1.26.3
uburp4:~/lang/py/webapi/crt$

次にバージョン不整合と怒られる

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.3) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

これは、requestを更新する

sudo python3 -m pip install --upgrade requests

uninstallするファイルがないというメッセージが気になるけど。。

$ sudo python3 -m pip install --upgrade requests
Collecting requests
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
     |????????????????????????????????| 61 kB 1.9 MB/s
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests) (2019.11.28)
Requirement already satisfied, skipping upgrade: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests) (1.26.3)
Requirement already satisfied, skipping upgrade: chardet<5,>=3.0.2 in /usr/lib/python3/dist-packages (from requests) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /usr/lib/python3/dist-packages (from requests) (2.8)
Installing collected packages: requests
  Attempting uninstall: requests
    Found existing installation: requests 2.22.0
    Not uninstalling requests at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'requests'. No files were found to uninstall.
Successfully installed requests-2.25.1