哈工大pyltp包安装过程

真的辛酸。先说环境win10 x64, python2.7

下载pyltp包

anaconda和pip都没有依赖,需要自己手动下载、配置。

下载pyltp并解压到任意位置

下载页面:https://github.com/hit-scir/pyltp

下载ltp并解压到任意位置

下载页面:https://github.com/hit-scir/ltp

将解压后的ltp文件夹命名为ltp,整体复制到pyltp中

也就是将ltp所有内容作为一个文件夹放到pyltp中。解压pyltp后所得到的文件夹中已经有一个名为ltp的空文件夹,把它覆盖即可。

安装C扩展包

对于Python 2.7 来说,微软直接推出了Microsoft Visual C++ Compiler for Python 2.7,下载直接安装即可。
http://www.microsoft.com/en-us/download/details.aspx?id=44266

这时候cmd进入pyltp包所在的位置,运行python setup.py install。

报错:error: command 'cl.exe' failed: No such file or directory

解决方案:

SET VCPYTHONPATH=C:\Users\用户名\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0

在python27安装目录下的 Lib\distutils\msvs9compiler.py中第254行

if not productdir or not os.path.isdir(productdir):
        toolskey = "VCPYTHONPATH"
        toolsdir = os.environ.get(toolskey, None)

        if toolsdir and os.path.isdir(toolsdir):
            productdir = os.path.abspath(toolsdir)
            if not os.path.isdir(productdir):
                log.debug("%s is not a valid directory" % productdir)
                return None
        else:
            log.debug("Env var %s is not set or invalid" % toolskey)

报错:error: command 'C:\\Users\\用户名\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

直到一万年以后,我才发现上面下载的C++扩展程序根本不支持win10...它只支持win7和win8。

所以现在的任务就是找到适合win10的py2.7的C++扩展。

解决方案:.net Framework 3.5 开启C++选项。

部署模型文件

完整的模型文件下载地址: http://pan.baidu.com/share/link?shareid=1988562907&uk=2738088569,我选择的是目前最新的3.4.0版本(ltp-data-v3.4.0.zip)。

参考:


 

猜你喜欢

转载自blog.csdn.net/qq_40136685/article/details/90675432