Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I recently downloaded Ubuntu 14.04 desktop version alongside Windows 10.

My PC configs are: 4 GB RAM, 64 bit

I installed Anaconda after downloading the file using: bash Anaconda3-2.5.0-Linux-x86_64.sh

Installation was successful.

Now in my ubuntu terminal, I follwed 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'

  1. sudo apt-get install python-setuptools (Successful)
  2. cd python-package
  3. sudo python setup.py install

The 5. command returns an error after a lot of lines:

'ImportError: No module named numpy.distutils.core'

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

like image 797
Siddharth Vashishtha Avatar asked Feb 11 '16 06:02

Siddharth Vashishtha


People also ask

How to fix importerror no module named NumPy in Python?

As a result, if don’t have numpy installed in your python, it’ll throw ImportError No Module Named Numpy. Either you need to change the environment to Anaconda’s environment or install numpy on the default environment. The process to install numpy on the default environment is already mentioned in the above (Windows) section.

How to install NumPy in Ubuntu and Windows?

Follow these steps to install numpy in Windows – Firstly, Open Command Prompt from the Start Menu. Enter the command pip install numpy and press Enter. Wait for the installation to finish. Test the installation by using import numpy command in Python Shell. Generally, in Ubuntu, there are multiple versions of Python installed.

How to fix “no module named NumPy error in Anaconda?

This environment is separated from your outside installed python and can lead to import No Module Named Numpy errors. Usually, numpy is already installed in anaconda but to install numpy again in Anaconda – Open Anaconda Prompt from Start Menu. Enter the command conda install numpy and Hit Enter.

Why is the module not found in Ubuntu 20?

The module not found likely means the packages aren't installed. If they're already installed you can try to fix anything that may have been messed up in the upgrade with... Show activity on this post. I got this problem after upgrading to Ubuntu 20.04.


2 Answers

I had the same problem today. I believe the issue is the instructions you listed are out of date for Python installs, as they are now enabled with pip install.

Delete the xgboost directory that your above install attempt created, and then execute:

pip install xgboost

It should all work with one command. See also the Python Specific XGBoost Install Instructions.

like image 77
Jacob Avatar answered Nov 08 '22 20:11

Jacob


This issue is listed in xgboost's github

The solution is

sudo -s

python setup.py install

instead of

cd python-package; sudo python setup.py install

like image 36
ANKESH KHEMANI Avatar answered Nov 08 '22 19:11

ANKESH KHEMANI