【问题标题】:How to install xgboost python wrapper in macOS virtualenv properly?如何在 macOS virtualenv 中正确安装 xgboost python 包装器?
【发布时间】:2017-01-04 21:18:50
【问题描述】:

在 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 中,该人建议从setup.py 中删除"include_package_data=True"。我这样做了,然后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'

如何解决这个问题?

【问题讨论】:

    标签: python macos installation virtualenv xgboost


    【解决方案1】:

    作为一种解决方法,我做了:

    import sys
    sys.path.append('<your-path-here>/xgboost/python-package')
    

    【讨论】:

      【解决方案2】:

      你可以只评论这些行,然后它就可以正常工作了!

      【讨论】:

      • 我应该评论哪些行?
      猜你喜欢
      • 1970-01-01
      • 2017-01-11
      • 1970-01-01
      • 2018-05-19
      • 2017-01-26
      • 1970-01-01
      • 2016-02-18
      • 1970-01-01
      • 2014-02-10
      相关资源
      最近更新 更多