在virtualenv下,我正在尝试使用official installation guide安装python包装器。当我做的时候
sudo python setup.py install
我收到了错误:
Install libxgboost from: ['/Users/dmitry/dev/mlenv/xgboost/xgboost/python-package/xgboost/../../lib/libxgboost.so']
running install
running bdist_egg
running egg_info
creating xgboost.egg-info
writing xgboost.egg-info/PKG-INFO
writing dependency_links to xgboost.egg-info/dependency_links.txt
writing requirements to xgboost.egg-info/requires.txt
writing top-level names to xgboost.egg-info/top_level.txt
writing manifest file 'xgboost.egg-info/SOURCES.txt'
reading manifest file 'xgboost.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'xgboost/include'
warning: no files found matching '*' under directory 'xgboost/src'
warning: no files found matching '*' under directory 'xgboost/make'
warning: no files found matching '*' under directory 'xgboost/rabit'
warning: no files found matching '*' under directory 'xgboost/lib'
warning: no files found matching '*' under directory 'xgboost/dmlc-core'
warning: no previously-included files matching '*.o' found anywhere in distribution
warning: no previously-included files matching '*.a' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
writing manifest file 'xgboost.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.12-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/xgboost
copying xgboost/__init__.py -> build/lib/xgboost
copying xgboost/callback.py -> build/lib/xgboost
copying xgboost/compat.py -> build/lib/xgboost
copying xgboost/core.py -> build/lib/xgboost
copying xgboost/libpath.py -> build/lib/xgboost
copying xgboost/plotting.py -> build/lib/xgboost
copying xgboost/rabit.py -> build/lib/xgboost
copying xgboost/sklearn.py -> build/lib/xgboost
copying xgboost/training.py -> build/lib/xgboost
error: Error: setup script specifies an absolute path:
/Users/dmitry/dev/mlenv/xgboost/xgboost/python-package/xgboost/../../lib/libxgboost.so
setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.
在这篇文章https://stackoverflow.com/a/41061466中,该人建议从"include_package_data=True"
删除setup.py
。我做到了,然后成功安装了xgboost,即python -c "import xgboost; print(xgboost.__version__)"
输出0.6。
然而,当我在与xgboost_root_dir/python-package/
不同的文件夹中执行时,我得到:
python -c "import xgboost; print(xgboost.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/dmitry/dev/mlenv/lib/python3.6/site-packages/xgboost-0.6-py3.6.egg/xgboost/__init__.py", line 21, in <module>
with open(VERSION_FILE) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/dmitry/dev/mlenv/lib/python3.6/site-packages/xgboost-0.6-py3.6.egg/xgboost/VERSION'
如何解决此问题?
答案 0 :(得分:0)
作为解决方法,我做了:
import sys
sys.path.append('<your-path-here>/xgboost/python-package')
答案 1 :(得分:-2)
你可以只评论这些行,然后就可以正常工作了!