`

python mmseg WindowsError: [Error 126]

阅读更多
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Function:
【记录】折腾Python中的mmseg中文分词模块

http://www.crifan.com/try_python_mmseg_chinese_segment_on_mmseg_algorithm

Author:     Crifan Li
Version:    2013-01-02
Contact:    admin at crifan dot com
"""

from mmseg import seg_txt;

def tryMmseg():
    for i in seg_txt("最主要的更动是:张无忌最后没有选定自己的配偶。"):
        print i;

if __name__ == "__main__":
    tryMmseg();
结果出错了:

E:\Dev_Root\python\try_mmseg>try_mmseg.py
Traceback (most recent call last):
  File "E:\Dev_Root\python\try_mmseg\try_mmseg.py", line 13, in <module>
    from mmseg import seg_txt;
  File "E:\dev_install_root\Python27\lib\site-packages\mmseg-1.3.0-py2.7-win-amd64.egg\mmseg\__init__.py", line 3, in <m
odule>
    import _mmseg as mmseg
  File "E:\dev_install_root\Python27\lib\site-packages\mmseg-1.3.0-py2.7-win-amd64.egg\mmseg\_mmseg.py", line 28, in <mo
dule>
    mmseg = cdll.LoadLibrary(mmseg_lib_path)
  File "E:\dev_install_root\Python27\lib\ctypes\__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  File "E:\dev_install_root\Python27\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126]


【解决过程】

1.以为是代码中导入有问题呢。

所以参考:

mmseg 1.3.0

去执行search结果也是同样错误:

E:\Dev_Root\python\try_mmseg>python -m mmseg.search
Traceback (most recent call last):
  File "E:\dev_install_root\Python27\lib\runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "E:\dev_install_root\Python27\lib\runpy.py", line 101, in _get_module_details
    loader = get_loader(mod_name)
  File "E:\dev_install_root\Python27\lib\pkgutil.py", line 456, in get_loader
    return find_loader(fullname)
  File "E:\dev_install_root\Python27\lib\pkgutil.py", line 466, in find_loader
    for importer in iter_importers(fullname):
  File "E:\dev_install_root\Python27\lib\pkgutil.py", line 422, in iter_importers
    __import__(pkg)
  File "E:\dev_install_root\Python27\lib\site-packages\mmseg-1.3.0-py2.7-win-amd64.egg\mmseg\__init__.py", line 3, in <m
odule>
    import _mmseg as mmseg
  File "E:\dev_install_root\Python27\lib\site-packages\mmseg-1.3.0-py2.7-win-amd64.egg\mmseg\_mmseg.py", line 28, in <mo
dule>
    mmseg = cdll.LoadLibrary(mmseg_lib_path)
  File "E:\dev_install_root\Python27\lib\ctypes\__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  File "E:\dev_install_root\Python27\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126]
2.去查了下,知道了错误的意思,就是没有找到对应的dll库,说白了,就是之前没有正常的完整编译mmseg,所以后来误以为正确安装,此处运行代码出错。

3.关于此,专门去删除了旧的mmseg-1.3.0,重新解压了一份mmseg-1.3.0,然后再去setup.py install结果的确是无法正常编译。所以验证了此处的猜测:

没有正常编译和安装mmseg,导致此处的WindowsError: [Error 126]的错误。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics