Xgboost package on mac - python

I am trying to use Xgboost but facing problems in installation.
i am using mac and I use python notebook jupyter for the same. I opened the command line and used pip install xgboost and it got installed successfully but when I try to use it in my code by writing import xgboost as xg then I get ImportError: No module named xgboost
Can anyone help me?

It may come from the fact that you have two (or more) python environments. A hacky solution is to install it within Jupyter Notebook (note the '!'):
!pip install xgboost

Related

ModuleNotFoundError: No module named 'sklearn.model_selection'; 'sklearn' is not a package

I have been dealing with this much too long. I am using a MacBook Pro. This suddenly started happening when running Jupyter. I could not fix it. I completely uninstalled anaconda (which was using Python3.8) then completely uninstalled Python3.9. I installed Python3.96. Then went back to basics and reinstalled numpy, pandas, sklearn. Everything seems to be there in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
This command fails in IDLE and gives the error in the title of my question.
from sklearn.model_selection import train_test_split
It does not give the error in Mac's Terminal
The search path for IDLE looks correct.
You can use pip to install it.
And it's called scikit-learn instead of sklearn in pip, if you are using Jupyter, do
!pip install scikit-learn
If you already have it, try
!pip install --upgrade scikit-learn
So after a few weeks of simply using Googles Colab I did the following. Purchased App Cleaner and Uninstaller for Mac and got rid of all Python related apps that I do not need any more after moving to Colab and Kaggle's API. Removed and reinstalled Python. Ran the Idle program again and it worked! Yay!. The problem started while using Jupiter with Anaconda. Just randomly appeared. When I decided to work on it again yesterday I thought it might have been some malware on my Mac. The reason I thought it was malware is that the Idle message was giving me the message that sklearn was not a package and it could not find train_test split - even when I asked for another sklearn module - e.g. datasets. It always referred to train_test_split even when I did not request it. Hence the cleanup of my Mac (everything Python related and more). It's all good now.

ModuleNotFoundError: No module named 'mlxtend' despite mlxtend being in pip list

I am using Python 3.8.6, with mlxtend version 0.17.3, doing this on jupyter notebook
I have installed mlxtend in my virtual environment on command prompt with
pip install mlxtend
and it also shows up on my pip list.
However when I am trying to import the module within VS Code, and selecting my venv as my python interpreter:
from mlxtend.feature_selection import SequentialFeatureSelector as SFS
I am facing the error:
ModuleNotFoundError: No module named 'mlxtend'
Appreciate any help.
Try pip list or import mlxtend in the console displaying error message. If it wasn't present there, it was an environment configuration problem. Then you can just install the module there using pip.
I remember one of my friends having same problem with some other module. He was also using some kind virtual environment, which I guess caused the problem.
The error is because of environment, and I had a similar problem, but I solved it by adding the isntalled library, in the Interpreter settings, but I did this in PyCharm, look for similar options in VS Code.
P.S. I will update if I found the option in VS.

ImportError: cannot import name 'CUDF_INSTALLED' from 'xgboost.compat'

Good evening.
I just helped someone with an xgboost install via anaconda, by using the line:
conda install -c conda-forge xgboost
And the line in the title is what I was given:
ImportError: cannot import name 'CUDF_INSTALLED' from 'xgboost.compat' (/opt/anaconda3/lib/python3.8/site-packages/xgboost/compat.py)
Google does not provide a lot of insight with respect to how to handle this particular error message.
What would be causing this problem?
I installed xgboost with using:
brew install xgboost
Then I got the same error. Close all running jupyter notebooks and restart anaconda. It works for me.

Errors while installing sklearn

I've been trying to install sklearn manually using pip with python 3.6 and i'm facing a lot of trouble. I couldn't get it installed cuz there was a problem with scipy.
I installed pycharm and tried to install both of them using the Packages interfaces and i'm still getting an error while trying to install sklearn.
NB: I installed scipy and numpy+mkl using their whl files
The module name is scikit-learn, not sklearn.

TensorFlow installation results in ImportError: No module named tensorflow

I'm trying to get TensorFlow to work on my Mac (OSX El Capitan 10.11.2). I tried the pip install from the setup guide and also followed the instructions in the accepted answer here.
In both cases I am able to successfully activate the virtualenv and my prompt changes to tensorflow. Python works fine, I'm able to do simple computations on the command line. But when I try to import tensorflow:
import tensorflow as tf
I repeatedly get this error:
ImportError: No module named tensorflow
Any help would be appreciated.
I had the issue reported in the original question. Python worked fine, I followed the installation steps on the Tensforflow website, and got "No module named tensorflow."
Re-installing python via brew, and re-installing pip as a result, fixed it. I didn't need to uninstall anything, just the line below along with the normal pip install from the tensorflow installation document afterwards:
brew install python

Categories

Resources