When I tried import from python terminal I get this error, although I followed all the steps to install xgboost, somehow python is unable to get the package details.I am relatively new to python, I could easily install numpy and pandas packages,I used this link for installation on MACOSX
>>> import xgboost Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named xgboost When I did pip install xgboost, I am getting this error,
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/h7/pyph_7qj6171tqp50cf2xc7m0000gn/T/pip-build-TEvbD6/xgboost/ I am getting this on printing sys path,
print sys.path
['', '/System/Library/Frameworks/ '/System/Library/Frameworks/ '/System/Library/Frameworks/ '/System/Library/Frameworks/ '/System/Library/Frameworks/ '/System/Library/Frameworks/ '/System/Library/Frameworks/ '/System/Library/Frameworks/ '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/ '/System/Library/Frameworks/
914 Answers
First you need to get control of your python environment. Download the homebrew python by pasting these into a fresh terminal window
/usr/bin/ruby -e "$(curl -fsSL )" here you will be prompterd to enter your password. After homebrew is installed, install python with brew install python. Please check your installation with brew doctor and follow homebrew's suggestions.
Now, with a fresh terminal window, install xgboost from pip. Open terminal and paste this in:
pip install xgboost 5I had the same issue. I tried everything but the only solution that worked for me to was to install the whl file directly from here :
then you can do :
pip install yourFile.whl On windows I managed to just double click on the whl file and install it
Good luck
1FYI if you are using anaconda dist'n then need to do
conda install -c conda-forge xgboost Use conda install in Anaconda Powershell Prompt then use pip install
conda install -c conda-forge xgboost pip install xgboost git clone --recursive cd xgboost sudo cp make/minimum.mk ./config.mk; sudo make -j4; sh build.sh cd python-package python setup.py install Atleast Now I can import xgboost from terminal on macosx, I haven't been able to import it in jupyter notebook as yet.
1Try running
pip install xgboost in Anaconda prompt; it's important that you do it in Anaconda prompt so it is in same location as the Python you're using.
I tried
pip install xgboost and
pip3 install xgboost But it doesn't work
ModuleNotFoundError: No module named 'xgboost'
Finally I solved Try this in the Jupyter Notebook cell
import sys !{sys.executable} -m pip install xgboost Results:
Collecting xgboost Using cached xgboost-1.4.1-py3-none-win_amd64.whl (97.8 MB) Requirement already satisfied: scipy in c:\programdata\anaconda3\lib\site-packages (from xgboost) (1.5.2) Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (from xgboost) (1.19.2) Installing collected packages: xgboost Successfully installed xgboost-1.4.1 Write this on the terminal of Jupyter:
conda install -c anaconda py-xgboost 1On Pycharm you can go to Pycharm > Prefernces, go to the interpreter you have and install the xgboost package.
All you need within Jupyter Notebook cell is: try running 👇👇👇
import sys !{sys.executable} -m pip install xgboost 1- Open the terminal
- Type pip install xgboost and hit enter.
Make sure your internet connection is good.
Do not forget to crosscheck the successful installation of it in jupyter.
1Give the following commands a try.
pip install xgboost pip install plotly 1if you run
pip install xgboots
in command line and no result, run the same command in jupyter.
for ubuntu 18 LTS, this worked for me. cmake is a pre-requiste to it, so if you havent you would need to install that, currently at print its version 3.10 + minimum.
in terminal: sudo snap install cmake --classic
in jupyter notebook(if terminal just edit it) import sys !{sys.executable} -m pip install xgboost