最新消息:20190529 VPS服务器已从腾讯云香港换为Vultr新加坡,主题仍用朋友推荐的大前端D8

【未解决】Python中去运行mmseg代码结果出错:WindowsError: [Error 126]

Python crifan 1245浏览 0评论

【问题】

在折腾:

【记录】折腾Python中的mmseg中文分词模块

的过程中,先是在安装过程中出错:

【已解决】安装Python模块mmseg出错:error: Unable to find vcvarsall.bat

解决了后,结果编译后去链接,又出错:

【未解决】Python中安装mmseg时编译出错:LINK : error LNK2001: 无法解析的外部符号 initmmseg

结果期间,以为解决了。

所以,就去运行代码:

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Function:
【记录】折腾Python中的mmseg中文分词模块
https://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]的错误。

4.看来,还是先去解决:

【未解决】Python中安装mmseg时编译出错:LINK : error LNK2001: 无法解析的外部符号 initmmseg

才能解决此处的问题。

5.对于此问题,别人也遇到过:

[CPyUG] 安装 pymmseg 的问题

转载请注明:在路上 » 【未解决】Python中去运行mmseg代码结果出错:WindowsError: [Error 126]

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
65 queries in 0.088 seconds, using 18.64MB memory