mmrotate icon indicating copy to clipboard operation
mmrotate copied to clipboard

[Bug] urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1131)>

Open huyi666r opened this issue 1 year ago • 1 comments

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

master branch https://github.com/open-mmlab/mmrotate

Environment

addict 2.4.0 certifi 2023.5.7 charset-normalizer 3.1.0 click 8.1.3 colorama 0.4.6 contourpy 1.1.0 cycler 0.11.0 e2cnn 0.2.3 fonttools 4.40.0 idna 3.4 importlib-metadata 6.7.0 importlib-resources 5.12.0 kiwisolver 1.4.4 Markdown 3.4.3 markdown-it-py 3.0.0 matplotlib 3.7.1 mdurl 0.1.2 mkl-fft 1.3.6 mkl-random 1.2.2 mkl-service 2.4.0 mmcv-full 1.7.1 mmdet 2.28.2 mmrotate 0.3.4 /home/hqt/MyProgram/mmrotate model-index 0.1.11 mpmath 1.3.0 numpy 1.24.3 opencv-python 4.8.0.74 opendatalab 0.0.9 openmim 0.3.9 ordered-set 4.1.0 packaging 23.1 pandas 2.0.3 Pillow 9.3.0 pip 23.1.2 platformdirs 3.8.0 pycocotools 2.0.6 pycryptodome 3.18.0 Pygments 2.15.1 pyparsing 3.1.0 python-dateutil 2.8.2 pytz 2023.3 PyYAML 6.0 requests 2.31.0 rich 13.4.2 scipy 1.10.1 setuptools 67.8.0 six 1.16.0 sympy 1.12 tabulate 0.9.0 terminaltables 3.1.10 tomli 2.0.1 torch 1.8.0 torchvision 0.9.0 tqdm 4.65.0 typing_extensions 4.6.3 tzdata 2023.3 urllib3 2.0.3 wheel 0.38.4 yapf 0.40.1 zipp 3.15.0

Reproduces the problem - code sample

try:
        try:
            # import ssl
            # ssl._create_default_https_context = ssl._create_unverified_context
            h.request(req.get_method(), req.selector, req.data, headers,
                      encode_chunked=req.has_header('Transfer-encoding'))
        except OSError as err: # timeout error
            raise URLError(err)
        r = h.getresponse()
    except:
        h.close()
        raise

The third and fourth lines of code were added by myself, but I still reported an error after adding it, and line 8 is where the error was reported

Reproduces the problem - command or script

python tools/train.py /home/hqt/MyProgram/mmrotate_faster_rcnn/mmrotate/configs/rotated_faster_rcnn/rotated_faster_rcnn_r50_fpn_1x_dota_le90.py --work-dir /home/hqt/MyProgram/mmrotate_faster_rcnn/mmrotate/save

Reproduces the problem - error message

Traceback (most recent call last): File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/urllib/request.py", line 1356, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/http/client.py", line 1256, in request self._send_request(method, url, body, headers, encode_chunked) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/http/client.py", line 1302, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/http/client.py", line 1251, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/http/client.py", line 1011, in _send_output self.send(msg) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/http/client.py", line 951, in send self.connect() File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/http/client.py", line 1425, in connect self.sock = self._context.wrap_socket(self.sock, File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/ssl.py", line 1040, in _create self.do_handshake() File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1131)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/train.py", line 194, in main() File "tools/train.py", line 167, in main model.init_weights() File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/base_module.py", line 117, in init_weights m.init_weights() File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/base_module.py", line 106, in init_weights initialize(self, self.init_cfg) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/cnn/utils/weight_init.py", line 636, in initialize _initialize(module, cp_cfg) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/cnn/utils/weight_init.py", line 539, in _initialize func(module) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/cnn/utils/weight_init.py", line 509, in call load_checkpoint( File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/checkpoint.py", line 638, in load_checkpoint checkpoint = _load_checkpoint(filename, map_location, logger) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/checkpoint.py", line 572, in _load_checkpoint return CheckpointLoader.load_checkpoint(filename, map_location, logger) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/checkpoint.py", line 314, in load_checkpoint return checkpoint_loader(filename, map_location) # type: ignore File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/checkpoint.py", line 481, in load_from_torchvision return load_from_http(model_urls[model_name], map_location=map_location) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/checkpoint.py", line 358, in load_from_http checkpoint = load_url( File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/torch/hub.py", line 524, in load_state_dict_from_url download_url_to_file(url, cached_file, hash_prefix, progress=progress) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/site-packages/torch/hub.py", line 394, in download_url_to_file u = urlopen(req) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/urllib/request.py", line 525, in open response = self._open(req, data) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/urllib/request.py", line 542, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/urllib/request.py", line 502, in _call_chain result = func(*args) File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/urllib/request.py", line 1399, in https_open return self.do_open(http.client.HTTPSConnection, req, File "/home/hqt/anaconda3/envs/mmrotate/lib/python3.8/urllib/request.py", line 1359, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1131)>

Additional information

No response

huyi666r avatar Jul 09 '23 08:07 huyi666r

I have solved it

huyi666r avatar Jul 09 '23 10:07 huyi666r