2

xgboost is recognized in terminal but not in Rodeo GUI

I've been trying to install xgboost since last night, but I just can't seem to get it to work. My latest development so far is that I am able to successfully call on the module when using the terminal, but it has an ImportError when using my Rodeo GUI, also in atom-hydrogren. Any tips how I can call xgboost for these?

Here 's a screencap for importing xgboost:

  1. Success:

Success!

  1. Failure:

    >>> import xgboost ImportError: No module named xgboost

Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97
jbolilia
  • 163
  • 1
  • 8

1 Answers1

1

Rodeo and Mac Terminal use different versions of Python and obviously different PYTHONPATH with their own set of libraries.

When you installed xgboost with git, you used the Terminal which is configured to use Python 2.7.10 (probably pre-installed with the OS). However, it is not installed in the package site that Rodeo uses.

You have two options:

  1. Make Rodeo use the package site that the Terminal uses
  2. Install xgboost in Rodeo's package site

Since you stated that Rodeo is installed alongside with Anaconda, I'd go with option 2. Anaconda has a lot of useful packages pre-installed that don't come along with the pre-installed libraries that the Terminal uses.

You could follow this link to install xgboost in Anaconda. After which, it should work fine with Rodeo.

Otherwise, you could try this code directly in Rodeo:

import pip

pip.main(['install','xgboost'])

If xgboost cannot compile, then it means that you don't have a compatible compiler to build it. To build it in a Mac, do the following (provided you have Homebrew)

brew install gcc5 --without-multilib

and then install xgboost with pip.

Community
  • 1
  • 1
Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97
  • Followed the link you provided and now I can import xgboost, but I get this error when loading pandas. ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96 – jbolilia Dec 11 '16 at 05:15
  • @jbolilia Did you use `conda` or `pip`? Could you follow [this solution](http://stackoverflow.com/a/37025618/4565943) in that post. – Ébe Isaac Dec 11 '16 at 05:18
  • also is there a way for me to just use one python? the anaconda path is exported in my `.bash_profile`. (`export PATH=$PATH:/Users/jbolilia/anaconda/bin`) – jbolilia Dec 11 '16 at 05:18
  • Yup I used `conda`! That's exactly the solution I followed. Asked me to downgrade some packages, pandas wasn't included. – jbolilia Dec 11 '16 at 05:20
  • @jbolilia Then try uninstalling it `conda remove xgboost` and then use the `pip` solution in Rodeo in my post. – Ébe Isaac Dec 11 '16 at 05:21
  • @jbolilia *is there a way for me to just use one python?* Yes, that is what I did too, only that you would have to give preference to the Anaconda packages first like so: `export PATH=/Users/jbolilia/anaconda/bin:$PATH` – Ébe Isaac Dec 11 '16 at 05:23
  • I uninstalled xgboost, but it still doesn't recognize my pandas, so I can't run my rodeo IDE. – jbolilia Dec 11 '16 at 05:39
  • @jbolilia Does that mean you were able to run the Rodeo before but not after trying to install `xgboost` with `conda`? – Ébe Isaac Dec 11 '16 at 05:40
  • Yes, I also use `atom` as my text editor sometimes with the `hydrogen` package which calls on my anaconda distribution. It also cannot recognize pandas after installing `xgboost` using `conda`. You think I should just uninstall everything and do it all over again, if so how can I do this to ensure that all the files are definitely cleaned out? – jbolilia Dec 11 '16 at 05:43
  • @jbolilia Well, we can leave that for a last resort. For now, update `pandas` with `conda update pandas`, and try again, then report what you find. – Ébe Isaac Dec 11 '16 at 05:45
  • Based on what I saw, it seems that `conda` install did not directly downgrade `pandas`, but did so four of its dependencies. I've updated `pandas` successfully and implemented the `pip` code above. However, I got this error: `Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/y4/q675pmbj4kj79h8cnz4vnpg00000gn/T/pip-build-blQ1lY/xgboost/ 1` – jbolilia Dec 11 '16 at 05:51
  • This means you don't have a suitable compiler to build the `xgboost` package. Do you use Homebrew? If so, do `brew install gcc5 --without-multilib` in Terminal and then try again. – Ébe Isaac Dec 11 '16 at 05:52
  • Finally got it to work! Does this also mean that `gcc` is my default compiler now? – jbolilia Dec 11 '16 at 06:02
  • @jbolilia Mabe so, but it should be for the best. So all is well now for both `xgboost` and `Rodeo`. PS: also make that `export` order switch so that even the `git` packages install at the right location in the future. – Ébe Isaac Dec 11 '16 at 06:03
  • already, did the export switch. thanks so much for all the help! – jbolilia Dec 11 '16 at 06:29
  • @jbolilia Happy to help. Bear in mind that you are using Python 2.7; it's [end of life period](https://pythonclock.org/) is getting closer. You ought to consider switching to Python 3.x in the near future. – Ébe Isaac Dec 11 '16 at 06:32
  • Yup, I have a 3.5 environment that I use sometimes, but I'll maybe use it more often. Thanks again! – jbolilia Dec 11 '16 at 15:02