HanLP icon indicating copy to clipboard operation
HanLP copied to clipboard

始终报file is not a zip file

Open landseer-ge opened this issue 3 years ago • 3 comments

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

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Python version:3.8.17
  • HanLP version:2.1.0-beta.50
  • Pytorch 2.0.1+cu117
  • linux-4.15.0-142-generate-x86_64-with-glibc2.17

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.

  • [x] I've completed this form and searched the web for solutions.

landseer-ge avatar Sep 06 '23 11:09 landseer-ge

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

landseer-ge avatar Sep 06 '23 13:09 landseer-ge

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

??? 什么网?

rm -rf ~/.hanlp

然后重试下载。

hankcs avatar Sep 07 '23 03:09 hankcs

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

您好,我也遇到这个问题了,最后你解决了吗?

benshan123 avatar May 05 '25 11:05 benshan123