真的辛酸。先说环境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 = "VCPYTHO