python - 无法在 Python 中导入名称模型
问题描述
我正在使用hazm
以提取文本中的块python 2.7
(由于库兼容性,使用旧版本的python)
总而言之,我必须引用一个名为postagger.model
folows 的模型:
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
解决方案
似乎错误不在您的代码中。如果您尚未安装 WSL,hazm 会给出此错误。有关更多信息,请参阅 Github 上的此问题:
推荐阅读
- python - background_gradient 按数据框而不是按列或行
- c++ - 通过选择以升序打印数组中的值的好处?
- pyspark - 如何在本地开发和测试 python 转换代码?
- delphi-10.3-rio - Metropolis如何设置父子窗体?
- python-3.x - 熊猫数据框整列到字符串数据类型
- exception - Typo3 缓存刷新异常 - 如何调试
- c++ - 为什么它不返回任何东西?
- python - 如何在python中发布xml
- apollo-server - 如何在 VS Code 中调试我的 typegraphql 解析器?
- flutter - 在颤动中创建具有动态页面数的页面浏览量