我正在尝试在我的Mac上为Python 3.4安装xgboost但是在“pip3 setup.py install”之后我收到以下错误:
File "<string>", line 20, in <module>
File "/private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost/setup.py", line 28, in <module>
execfile(libpath_py, libpath, libpath)
NameError: name 'execfile' is not defined
使用-v选项运行它以获取详细输出时,错误如下所示:
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost
Exception information:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/commands/install.py", line 339, in run
requirement_set.prepare_files(finder)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/req/req_set.py", line 385, in prepare_files
req_to_install.run_egg_info()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/req/req_install.py", line 358, in run_egg_info
command_desc='python setup.py egg_info')
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/utils/__init__.py", line 749, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost
我该如何解决这个问题?
答案 0 :(得分:5)
这对我有用。
操作系统:OSX El Capitan
步骤1:cd xgboost; ./build.sh
第2步:cd python-package; python setup.py install
答案 1 :(得分:2)
我认为xgboost只是作为Python 2包而不是pip。 有两种可能性让它发挥作用。
答案 2 :(得分:0)
也许你应该使用
cd xgboost; cp make/minimum.mk ./config.mk; make -j4
而不是
cd xgboost; ./build.sh
根据&#34; Build On OSX&#34;构建文档部分
也许这是一个duplicate
答案 3 :(得分:0)
按照指示building from sources,尝试在Mac OS X Mojave 10.14上安装XGBoost时遇到很多错误。最糟糕的情况是调用CMake无法正常工作,并且臭名昭著的clang:错误不受支持的选项'-fopenmp'。真正的C ++构建/编译噩梦...
由于我最终无法编译本机C ++库,因此我成功使用了此替代方法:
使用brew获取编译的库libxgboost.dylib:
brew install xgboost
奇怪的是,brew并没有安装整个东西!!?
安装Python库:
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
安装编译的库libxgboost.dylib并链接到它:
mkdir lib
cd lib
ln -s /usr/local/Cellar/xgboost/0.90/lib/libxgboost.dylib ./libxgboost.dylib
安装Python软件包
cd ../python-package
sudo python3 setup.py install
同样,奇怪的是,setup.py会部分安装egg软件包,因此我必须手动将xgboost软件包目录复制到site-packages。
cp -r xgboost /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/
顺便说一句,我也要升级dask:sudo pip3 install --upgrade dask