您的位置:首页 > 运维架构 > Linux

linux下python导入xgboost出现的问题小结

2017-04-17 17:19 495 查看
在python导入import xgboost出现如下错误:

./lib/libgomp.so.1: version `GOMP_4.0' not found (required by /home/yin/anaconda3/lib/python3.5/site-packages/xgboost-0.6-py3.5.egg/xgboost/libxgboost.so)
上面显示的意思是在$PYTHON_HOME/lib/libgomp.so.1中没有‘GOMP_4.0',这个可以使用strings命令查看libgomp.so.1这个文件,显示如下只有到_3.0版本

GOMP_1.0
GOMP_2.0
GOMP_3.0
GOMP_CPU_AFFINITY
因为$PYTHON_HOME/lib/libgomp.so.1是一个链接文件,所以使用locate命令搜系统中所有的libgomp.so.1,显示的结果
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgomp.so
/usr/lib/gcc/x86_64-linux-gnu/5/libgomp.so
/usr/lib/x86_64-linux-gnu/libgomp.so.1
/usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0
可以使用strings命令查看上面结果哪一个文件包含GOMP_4.0,在本机中/usr/lib/x86_64-linux-gnu/libgomp.so.1包含了该字符串(说明它包含GOMP_4.0)

下面删掉旧的$PYTHON_HOME/lib/libgomp.so.1,重新做一个新的链接

ln -s /usr/lib/x86_64-linux-gnu/libgomp.so.1 libgomp.so.1


在pyton中测试import xgboost,又出现了下面的问题,使用相同的方法,替换掉python下对应的链接文件libstdc++.so.6即可

scipy libstdc++.so.6: version `GLIBCXX_3.4.21'


最终替换掉2个文件后,在python可正常导入xgboost...O(∩_∩)O~~

问题剖析:

因为之前的xgboots是使用gcc5.0编译的,而python2.7依赖于gcc4.7。在python中低版本调用了高版本的gcc库文件,从而导致了这个错误。

参考:
https://github.com/dmlc/xgboost/issues/1786 https://xgboost.readthedocs.io/en/latest/build.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐