运行demo_cws.py和demo_cws_trie.py两文件报错。

运行HanLP中的tests下分词demo报错。w
demo_cws.py和demo_cws_trie.py两文件,未改动任何代码,均报:
TypeError: argument of type ‘module’ is not iterable
环境:win10
python 3.7.0
hanlp:(2.0.0a61) 但程序报错我为 2.0.0-alpha.38
看了下
pku98_6m_conv_ngram_20200110_134736.zip 下载解压成功了的,也删除过重新下载。
想问下是不是python版本和其他包环境版本的问题。
报错代码:

from hanlp.common.trie import Trie

import hanlp

tokenizer = hanlp.load('PKU_NAME_MERGED_SIX_MONTHS_CONVSEG')
text = 'NLP统计模型没有加规则,聪明人知道自己加。英文、数字、自定义词典统统都是规则。'
print(tokenizer(text))

==================
报错详情:

    Failed to load https://file.hankcs.com/hanlp/cws/pku98_6m_conv_ngram_20200110_134736.zip. See stack trace below
Traceback (most recent call last):
  File "D:\wamp64\www\HanLP\hanlp\utils\component_util.py", line 48, in load_from_meta_file
    obj.load(save_dir, **load_kwargs)
  File "D:\wamp64\www\HanLP\hanlp\common\component.py", line 244, in load
    self.build(**merge_dict(self.config, training=False, logger=logger, **kwargs, overwrite=True, inplace=True))
  File "D:\wamp64\www\HanLP\hanlp\common\component.py", line 257, in build
    optimizer = self.build_optimizer(**self.config)
  File "D:\wamp64\www\HanLP\hanlp\common\component.py", line 289, in build_optimizer
    custom_objects=custom_objects)
  File "D:\Miniconda3\envs\for_hanlp\lib\site-packages\tensorflow\python\keras\utils\generic_utils.py", line 347, in deserialize_keras_object
    config, module_objects, custom_objects, printable_module_name)
  File "D:\Miniconda3\envs\for_hanlp\lib\site-packages\tensorflow\python\keras\utils\generic_utils.py", line 294, in class_and_config_for_serialized_keras_object
    cls = get_registered_object(class_name, custom_objects, module_objects)
  File "D:\Miniconda3\envs\for_hanlp\lib\site-packages\tensorflow\python\keras\utils\generic_utils.py", line 230, in get_registered_object
    elif module_objects and name in module_objects:
TypeError: argument of type 'module' is not iterable
https://file.hankcs.com/hanlp/cws/pku98_6m_conv_ngram_20200110_134736.zip was created with hanlp-2.0.0-alpha.13, while you are running 2.0.0-alpha.38. Try to upgrade hanlp with
pip install --upgrade hanlp
If the problem persists, please submit an issue to https://github.com/hankcs/HanLP/issues .

Process finished with exit code 1

文件加载失败了,看看是不是模型没有下载下来,可以尝试备用连接

字典目录
pku98_6m_conv_ngram_20200110_134736.zip 下载解压成功了的,也删除过重新下载。

应该是你安装了多个版本的hanlp的环境,正好import了2.0.0-alpha.38这个版本。你可以通过如下代码检查自己的版本:

import hanlp

print(hanlp.__version__)

的确是这样, pycharm里设了conda环境,但又从git上clone了一个项目,结果混了
:sweat_smile:谢谢回复