way1:pip install pyltp==0.2.1 -i https://pypi.douban.com/simple
安装未成功:中间安装编译过程超长,直接手动退出
way2:离线安装 :HIT-SCIR/pyltp: pyltp: the python extension for LTP (github.com)https://github.com/HIT-SCIR/pyltp
安装未成功:下载解压之后,python setup.py install 提示一下异常且不会修改:
subprocess.CalledProcessError: Command '['cmake', '/usr/neoapi/neo4j/pyltp-master', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/usr/neoapi/neo4j/pyltp-master/build/lib.linux-x86_64-3.7', '-DPYTHON_EXECUTABLE=/root/anaconda3/bin/python', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1
way3:离线安装 :
最终安装成功:
下载安装包并解压之后:直接python setup.py install 出现异常:
return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0;
^
error: command 'gcc' failed with exit status 1gcc -pthread -B /root/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iltp/include/ -Iltp/thirdparty/boost/include/ -Iltp/thirdparty/dynet/ -Iltp/thirdparty/eigen/ -Iltp/thirdparty/maxent/ -Iltp/src/ -Iltp/src/splitsnt -Iltp/src/segmentor/ -Iltp/src/postagger/ -Iltp/src/ner/ -Iltp/src/parser.n/ -Iltp/src/srl/ -Iltp/src/srl/common/ -Iltp/src/srl/include/ -Iltp/src/srl/Pi/ -Iltp/src/srl/Srl/ -Iltp/src/srl/tool/ -Iltp/src/utils/ -Ipatch/include/ -I/root/anaconda3/include/python3.7m -c patch/libs/python/src/converter/builtin_converters.cpp -o build/temp.linux-x86_64-3.7/patch/libs/python/src/converter/builtin_converters.o -std=c++0x cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default] In file included from patch/include/boost/python/handle.hpp:10:0, from patch/libs/python/src/converter/builtin_converters.cpp:6: patch/include/boost/python/cast.hpp: In function ‘void boost::python::detail::assert_castable(boost::type<Target>*)’: patch/include/boost/python/cast.hpp:73:20: warning: typedef ‘must_be_a_complete_type’ locally defined but not used [-Wunused-local-typedefs] typedef char must_be_a_complete_type[sizeof(T)]; ^ patch/libs/python/src/converter/builtin_converters.cpp: In function ‘void* boost::python::converter::{anonymous}::convert_to_cstring(PyObject*)’: patch/libs/python/src/converter/builtin_converters.cpp:51:64: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive] return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0; ^ error: command 'gcc' failed with exit status 1
参考:PYTLP模型安装及使用(linux+python3)_wangyueshu的博客-CSDN博客
可以解决。