如下图所示,运行demo_ner_dict.py时报错:提示需要升级为最新版本2.1.0-beta.17。
然而事实是我已在pip中升级为最新版本,且pycharm库中也显示的是17版本,不知为何报错依旧。
新人一个,恳请大家不吝赐教,感激涕零。
以下为错误日志:
OS: Windows-10-10.0.22000-SP0
Python: 3.8.3
PyTorch: 1.11.0+cpu
HanLP: 2.1.0-beta.16
Traceback (most recent call last):
File “C:/Users/77178/PycharmProjects/HanLP/plugins/hanlp_demo/hanlp_demo/zh/demo_ner_dict.py”, line 8, in
HanLP = hanlp.load(hanlp.pretrained.mtl.CLOSE_TOK_POS_NER_SRL_DEP_SDP_CON_ERNIE_GRAM_ZH)
File “C:\Users\77178\PycharmProjects\HanLP\hanlp_init_.py”, line 43, in load
return load_from_meta_file(save_dir, ‘meta.json’, verbose=verbose, **kwargs)
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\utils\component_util.py”, line 170, in load_from_meta_file
raise e from None
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\utils\component_util.py”, line 98, in load_from_meta_file
obj.load(save_dir, verbose=verbose, **kwargs)
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\common\torch_component.py”, line 178, in load
self.model = self.build_model(
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\components\mtl\multi_task_learning.py”, line 441, in build_model
transformer_module = encoder.module(training=training)
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\layers\embeddings\contextual_word_embedding.py”, line 160, in module
return ContextualWordEmbeddingModule(self.field,
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\layers\embeddings\contextual_word_embedding.py”, line 46, in init
super().init(transformer, transformer_tokenizer, average_subwords, scalar_mix, word_dropout,
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\layers\transformers\encoder.py”, line 73, in init
transformer = AutoModel_.from_pretrained(transformer, training=training or not trainable,
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\layers\transformers\pt_imports.py”, line 22, in from_pretrained
pretrained_model_name_or_path = get_model_mirror(pretrained_model_name_or_path)
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\layers\transformers\resource.py”, line 32, in get_model_mirror
return get_resource(m)
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\utils\io_util.py”, line 340, in get_resource
path = download(url=path, save_path=realpath, verbose=verbose)
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\utils\io_util.py”, line 185, in download
raise e from None
File “C:\Users\77178\PycharmProjects\HanLP\hanlp\utils\io_util.py”, line 155, in download
downloader.start_sync()
File “C:\Users\77178\PycharmProjects\HanLP\venv\lib\site-packages\hanlp_downloader\down.py”, line 114, in start_sync
self.run()
File “C:\Users\77178\PycharmProjects\HanLP\venv\lib\site-packages\hanlp_downloader\down.py”, line 154, in run
raise HTTPError(self.url, r.status_code, f’Internet error’, r.headers, None)
urllib.error.HTTPError: HTTP Error 404: Internet error
Download failed due to <HTTPError 404: ‘Internet error’>.
Please upgrade to the latest version (2.1.0b17) with:pip install -U hanlp