hankcs / HanLP

Natural Language Processing for the next decade. Tokenization, Part-of-Speech Tagging, Named Entity Recognition, Syntactic & Semantic Dependency Parsing, Document Classification
https://hanlp.hankcs.com/en/
Apache License 2.0
33.51k stars 9.99k forks source link

解析失败,提示升级hanlp #1855

Closed chn112211 closed 11 months ago

chn112211 commented 11 months ago

OS: Windows-10-10.0.19041-SP0 Python: 3.8.5 [2023-10-23 15:26:10,183] ERROR in app: Exception on /resumeFile [POST] Traceback (most recent call last): File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\hanlp\utils\component_util.py", line 99, in load_from_meta_file obj: Component = object_from_classpath(cls) File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\hanlp_common\reflection.py", line 27, in object_from_classpath classpath = str_to_type(classpath) File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\hanlp_common\reflection.py", line 44, in str_to_type cls = getattr(importlib.import_module(module_name), class_name) File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\importlib__init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\hanlp\components\ner\transformer_ner.py", line 9, in from hanlp.common.dataset import SamplerBuilder File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\hanlp\common\dataset.py", line 14, in import torch File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\init.py", line 1429, in from torch import optim as optim File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\optim\init__.py", line 8, in from .adadelta import Adadelta File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\optim\adadelta.py", line 4, in from .optimizer import (Optimizer, _use_grad_for_differentiable, _default_to_fused_or_foreach, File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\optim\optimizer.py", line 23, in from typing_extensions import ParamSpec, Self, TypeAlias ImportError: cannot import name 'ParamSpec' from 'typing_extensions' (C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\typing_extensions.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 2528, in wsgi_app response = self.full_dispatch_request() File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) File "D:\kzj\resume\hugh2020-haozhaome-hzm2_resume-\communicate.py", line 44, in get_resume_file info = send_info(uploadId, resume_list) File "D:\kzj\resume\hugh2020-haozhaome-hzm2_resume-\communicate.py", line 80, in send_info "resumesInfo": get_resumes_info(resume_list) File "D:\kzj\resume\hugh2020-haozhaome-hzm2_resume-\communicate.py", line 50, in get_resumes_info all_info = get_all_info(f"data/{resume.file_name}") File "D:\kzj\resume\hugh2020-haozhaome-hzm2_resume-\resume_parser\main.py", line 19, in get_all_info model = hanlp.load('https://file.hankcs.com/hanlp/ner/msra_ner_electra_small_20220215_205503.zip') File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\hanlp__init__.py", line 43, in load return load_from_meta_file(save_dir, 'meta.json', verbose=verbose, kwargs) File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\hanlp\utils\component_util.py", line 161, in load_from_meta_file import torch File "C:\Users\keith\AppData\Local\Programs\Python\Python38\lib\site-packages\torch__init__.py", line 465, in for name in dir(_C): NameError: name '_C' is not defined

hankcs commented 11 months ago

建议您读一读《提问的智慧》