hankcs / HanLP

中文分词 词性标注 命名实体识别 依存句法分析 成分句法分析 语义依存分析 语义角色标注 指代消解 风格转换 语义相似度 新词发现 关键词短语提取 自动摘要 文本分类聚类 拼音简繁转换 自然语言处理
https://hanlp.hankcs.com/
Apache License 2.0
33.97k stars 10.18k forks source link

始终报file is not a zip file #1840

Closed landseer-ge closed 1 year ago

landseer-ge commented 1 year ago

Describe the bug A clear and concise description of what the bug is. hanlp.load(hanlp.pretrained.pos.CTB9_POS_ELECTRA_SMALL)报错,说load_from_meta_file raise e from None,等于是load()函数下载的东西有问题,在zipfile解压的时候说不是zip文件。

Code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem.hanlp.load(hanlp.pretrained.pos.CTB9_POS_ELECTRA_SMALL)

Describe the current behavior A clear and concise description of what happened.在.hanlp/tok/安装网上下载的包也还是不能跑通

Expected behavior A clear and concise description of what you expected to happen.

System information

Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

landseer-ge commented 1 year ago

OS: Linux-4.15.0-142-generic-x86_64-with-glibc2.17 Python: 3.8.17 PyTorch: 2.0.1+cu117 HanLP: 2.1.0-beta.50 Traceback (most recent call last): File "han.py", line 6, in pos = hanlp.load(hanlp.pretrained.pos.C863_POS_ELECTRA_SMALL) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/init.py", line 43, in load return load_from_meta_file(save_dir, 'meta.json', verbose=verbose, kwargs) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/utils/component_util.py", line 186, in load_from_meta_file raise e from None File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/utils/component_util.py", line 106, in load_from_meta_file obj.load(save_dir, verbose=verbose, kwargs) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/common/torch_component.py", line 173, in load self.load_config(save_dir, kwargs) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/common/torch_component.py", line 125, in load_config self.config[k] = Configurable.from_config(v) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp_common/configurable.py", line 32, in from_config return cls.from_config(deserialized_config) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/common/transform.py", line 258, in from_config return cls(config) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/common/transform.py", line 480, in init mapper = get_resource(mapper) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/utils/io_util.py", line 341, in get_resource path = uncompress(path, verbose=verbose) File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/utils/io_util.py", line 260, in uncompress raise e File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/site-packages/hanlp/utils/io_util.py", line 225, in uncompress with zipfile.ZipFile(path, "r") if ext == '.zip' else tarfile.open(path, 'r:*') as archive: File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/zipfile.py", line 1269, in init self._RealGetContents() File "/media/disk2/gezilan/miniconda3/envs/myenv/lib/python3.8/zipfile.py", line 1336, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file

hankcs commented 1 year ago

在.hanlp/tok/安装网上下载的包也还是不能跑通

??? 什么网?

rm -rf ~/.hanlp

然后重试下载。