xgboost: ImportError: No module named numpy.distutils.core (Ubuntu xgboost installation)

I am a new user to Ubuntu and recently downloaded Ubuntu 14.04 desktop version alongside Windows 10.

My PC configs are: 4 GB RAM, 64 bit

I installed Anaconda using the following command from the terminal (after downloading from website): bash Anaconda3-2.5.0-Linux-x86_64.sh

Installation was successful.

Now in my ubuntu terminal, I followed steps as instructed on http://xgboost.readthedocs.org/en/latest/build.html#building-on-ubuntu-debian

  1. Installed a recent GNU C++ compiler -->successful
  2. git clone --recursive https://github.com/dmlc/xgboost cd xgboost; make -j4 Building was also successful and I could build ‘libxgboost.so’
  3. sudo apt-get install python-setuptools (Successful)
  4. cd python-package
  5. sudo python setup.py install

The 5. command returns an error after a number of lines. The error is as follows:

‘ImportError: No module named numpy.distutils.core’

Can anyone suggest how to get rid of this error so that I can install xgboost ?

The full log after step 5. is as follows:

sidvash@sidvash-HP-Pavilion-g6-Notebook-PC:~/xgboost/python-package$ sudo python setup.py install Install libxgboost from: [‘/home/sidvash/xgboost/python-package/xgboost/…/…/lib/libxgboost.so’] running install running bdist_egg running egg_info writing requirements to xgboost.egg-info/requires.txt writing xgboost.egg-info/PKG-INFO writing top-level names to xgboost.egg-info/top_level.txt writing dependency_links to xgboost.egg-info/dependency_links.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 previously-included files matching 'xgboost/build/’ found anywhere in distribution warning: no previously-included files matching ‘xgboost/.o’ 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.linux-x86_64/egg running install_lib running build_py creating build/bdist.linux-x86_64/egg creating build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/libpath.py -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/VERSION -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/build-python.sh -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/init.py -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/training.py -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/compat.py -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/core.py -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/sklearn.py -> build/bdist.linux-x86_64/egg/xgboost copying build/lib.linux-x86_64-2.7/xgboost/plotting.py -> build/bdist.linux-x86_64/egg/xgboost byte-compiling build/bdist.linux-x86_64/egg/xgboost/libpath.py to libpath.pyc byte-compiling build/bdist.linux-x86_64/egg/xgboost/init.py to init.pyc byte-compiling build/bdist.linux-x86_64/egg/xgboost/training.py to training.pyc byte-compiling build/bdist.linux-x86_64/egg/xgboost/compat.py to compat.pyc byte-compiling build/bdist.linux-x86_64/egg/xgboost/core.py to core.pyc byte-compiling build/bdist.linux-x86_64/egg/xgboost/sklearn.py to sklearn.pyc byte-compiling build/bdist.linux-x86_64/egg/xgboost/plotting.py to plotting.pyc installing package data to build/bdist.linux-x86_64/egg running install_data copying /home/sidvash/xgboost/python-package/xgboost/…/…/lib/libxgboost.so -> build/bdist.linux-x86_64/egg/xgboost creating build/bdist.linux-x86_64/egg/EGG-INFO copying xgboost.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying xgboost.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying xgboost.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying xgboost.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO copying xgboost.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying xgboost.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO creating ‘dist/xgboost-0.4-py2.7.egg’ and adding ‘build/bdist.linux-x86_64/egg’ to it removing ‘build/bdist.linux-x86_64/egg’ (and everything under it) Processing xgboost-0.4-py2.7.egg removing ‘/usr/local/lib/python2.7/dist-packages/xgboost-0.4-py2.7.egg’ (and everything under it) creating /usr/local/lib/python2.7/dist-packages/xgboost-0.4-py2.7.egg Extracting xgboost-0.4-py2.7.egg to /usr/local/lib/python2.7/dist-packages xgboost 0.4 is already the active version in easy-install.pth

Installed /usr/local/lib/python2.7/dist-packages/xgboost-0.4-py2.7.egg Processing dependencies for xgboost==0.4 Searching for scipy Reading https://pypi.python.org/simple/scipy/ Best match: scipy 0.17.0 Downloading https://pypi.python.org/packages/source/s/scipy/scipy-0.17.0.zip#md5=28a4fe29e980804db162524f10873211 Processing scipy-0.17.0.zip Writing /tmp/easy_install-2YPTnH/scipy-0.17.0/setup.cfg Running scipy-0.17.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-2YPTnH/scipy-0.17.0/egg-dist-tmp-z4NE5c Traceback (most recent call last): File “setup.py”, line 39, in <module> url=‘https://github.com/dmlc/xgboost’) File “/usr/lib/python2.7/distutils/core.py”, line 151, in setup dist.run_commands() File “/usr/lib/python2.7/distutils/dist.py”, line 953, in run_commands self.run_command(cmd) File “/usr/lib/python2.7/distutils/dist.py”, line 972, in run_command cmd_obj.run() File “/usr/lib/python2.7/dist-packages/setuptools/command/install.py”, line 73, in run self.do_egg_install() File “/usr/lib/python2.7/dist-packages/setuptools/command/install.py”, line 96, in do_egg_install cmd.run() File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 381, in run self.easy_install(spec, not self.no_deps) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 597, in easy_install return self.install_item(None, spec, tmpdir, deps, True) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 648, in install_item self.process_distribution(spec, dist, deps) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 694, in process_distribution [requirement], self.local_index, self.easy_install File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 620, in resolve dist = best[req.key] = env.best_match(req, ws, installer) File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 858, in best_match return self.obtain(req, installer) # try and download/install File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 870, in obtain return installer(requirement) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 616, in easy_install return self.install_item(spec, dist.location, tmpdir, deps) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 646, in install_item dists = self.install_eggs(spec, download, tmpdir) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 834, in install_eggs return self.build_and_install(setup_script, setup_base) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 1040, in build_and_install self.run_setup(setup_script, setup_base, args) File “/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”, line 1025, in run_setup run_setup(setup_script, args) File “/usr/lib/python2.7/dist-packages/setuptools/sandbox.py”, line 50, in run_setup lambda: execfile( File “/usr/lib/python2.7/dist-packages/setuptools/sandbox.py”, line 100, in run return func() File “/usr/lib/python2.7/dist-packages/setuptools/sandbox.py”, line 52, in <lambda> {‘file’:setup_script, ‘name’:‘main’} File “setup.py”, line 265, in <module>

File “setup.py”, line 253, in setup_package

ImportError: No module named numpy.distutils`_

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 17 (3 by maintainers)

Most upvoted comments

If ‘pip install xgboost’ doesn’t work for you, this issue can also be fixed by doing

sudo -s
python setup.py install 

The problem is ‘sudo python’ will use system’s Python instead of anacoda’s python.

More detail: http://stackoverflow.com/questions/30626160/anaconda-python-not-available-from-sudo

Thanks knguyen0105, Summary for Ubuntu, anaconda 2:

  1. http://xgboost.readthedocs.io/en/latest/build.html
  2. sudo -s python setup.py install instead of cd python-package; sudo python setup.py install