Ubuntu中conda虚拟环境安装kenlm步骤及报错整理
使用pycorrector进行文本纠错的过程中,需要安装kenlm库。遇到了各种各样的问题。先进行汇总整理,
首先通过一般的pip安装会报错,不能通过命令安装。
因此需要上传源码进行安装。
源码下载连接
访问密码:PQdjD
上传到服务器后,放到conda或python能访问到的目录进行解压。
运行以下命令安装
python setup.py install
r然后噩梦开始了。
1、第一个报错
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
pip安装Cmake
pip install Cmake
2、crypt.h:No such file or directory
Ubuntu安装libcrypt
apt install libcrypt
再安装install libc6-dev
sudo apt-get install libc6-dev
复制crypt.h到虚拟环境目录中
cp /usr/include/crypt.h /root/anaconda3/envs/xxxxx/include/python3.8/crypt.h
xxxxx是虚拟环境目录,按自己安装目录修改
3、接着报错
gcc: fatal error: cannot execute‘cclplus': execvp: No such file or directory compilation temminated.
运行下面的命令安装conda版本的gcc和gxx库
conda install -c conda-forge gcc=11 gxx=11
4、继续报错
root/anaconda3/envs/ht/compiler compat/ld: cannot find /lib64/libpthread.so.0: No such file or directory
root/anaconda3/envs/ht/compiler compat/ld: cannot find /usr/lib64/libpthread nonshared.a: No such file or directory
添加环境变量
export CFLAGS='-Wl,--sysroot=/root/anaconda3/envs/xxxxxx/x86_64-conda-linux-gnu/sysroot'
注意修改路径。
Ubuntu系统就是个坑,我在centos或者麒麟等其他系统安装的时候就没有报这么多错。以后安装系统还是使用centos或者衍生的系统吧。避坑!!