问题
I am trying to install xgboost on my Mac for Python 3.4 but I'm getting the following error after "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
When running it with the -v option to get the verbose output the error looks like this:
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
How can I solve this issue?
回答1:
This worked for me.
OS: OSX El Capitan
Step-1: cd xgboost; ./build.sh
Step-2: cd python-package; python setup.py install
回答2:
I think that xgboost is just available as Python 2 package over pip. There are two possibilities to get it working.
- You use Python 2 and install it with pip.
- You can manually build xgboost for Python 3. Just download the source from github and build it: Open Terminal. check out from git: git clone https://github.com/dmlc/xgboost.git. build it: cd xgboost; make; cd wrapper; python.py setup install --user
回答3:
perhaps you should use
cd xgboost; cp make/minimum.mk ./config.mk; make -j4
instead of
cd xgboost; ./build.sh
as per the "Build On OSX" Section of build document
also perhaps this is a duplicate
回答4:
I've got many errors trying to install XGBoost on a Mac OS X Mojave 10.14 following the instructions building from sources. The worst one was when invoking CMake didn't work and the infamous clang: error unsupported option '-fopenmp'. A real C++ build / compilation nightmare...
Since I was not able to compile the native C++ library finally I succeeded using this workaround procedure:
Using brew to get the compiled library libxgboost.dylib:
brew install xgboost
Strangely enough, brew didn't install the whole thing!!??
Install the Python library:
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
Install the compiled library libxgboost.dylib and link to it:
mkdir lib
cd lib
ln -s /usr/local/Cellar/xgboost/0.90/lib/libxgboost.dylib ./libxgboost.dylib
Install the Python package
cd ../python-package
sudo python3 setup.py install
Again, strangely enough, setup.py installs partially the egg package, so I have to copy manually the xgboost package directory to site-packages.
cp -r xgboost /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/
By the way, I've also to upgrade dask: sudo pip3 install --upgrade dask
来源:https://stackoverflow.com/questions/32838959/python-xgboost-on-mac-install