我使用hazm是为了使用python 2.7提取文本中的块(由于库的兼容性,我使用的是较旧版本的python )
在一行中,我必须引用一个名为postagger.model的模型,如下所示:
tagger = POSTagger(model='./resources/postagger.model')但我收到错误:无法导入名称模型
我不得不提一下,我已经创建了资源文件夹,并将postagger.model放在该文件夹中。
你能帮我解决我的项目出了什么问题吗?
谢谢
更新:我已经提到了完整的回溯错误消息:
ImportError at /testCore1
cannot import name Model
Request Method: GET
Request URL: http://127.0.0.1:8000/testCore1?sentence=gre
Django Version: 1.11.29
Exception Type: ImportError
Exception Value:
cannot import name Model
Exception Location: C:\Python27\lib\site-packages\hazm\SequenceTagger.py in __init__, line 22
Python Executable: C:\Python27\python27.exe
Python Version: 2.7.15
Python Path:
['C:\\Users\\user\\Desktop\\newapp',
'C:\\Windows\\SYSTEM32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages',
'C:\\Python27\\lib\\site-packages\\wapiti']
Server time: Tue, 28 Apr 2020 05:10:01 +0000
Traceback Switch to copy-and-paste view
C:\Python27\lib\site-packages\django\core\handlers\exception.py in inner
response = get_response(request) ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\handlers\base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\handlers\base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
C:\Users\user\Desktop\newapp\keywordextraction\views.py in testCore1
tagger = POSTagger(model='resources/postagger.model') ...
▶ Local vars
C:\Python27\lib\site-packages\hazm\SequenceTagger.py in __init__
from wapiti import Model ...
▶ Local vars发布于 2020-04-29 04:16:19
看起来错误并不在你的代码中。如果你还没有安装WSL,hazm会给出这个错误。有关更多信息,请参阅Github上的此问题:
https://stackoverflow.com/questions/61469198
复制相似问题