I face the following errors on jupyter notebook which I believe is due to because of multiple versions of python on my laptop, I am trying import xgboost
from xgboost import XGBClassifier
I get the following error,
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-4-3728958e329a> in <module>
15 from sklearn.svm import SVC
16 from sklearn.neural_network import MLPClassifier
---> 17 from xgboost import XGBClassifier
ModuleNotFoundError: No module named 'xgboost'
and I also get the following warnings when I run the kfold
selection,
# evaluate each model in turn
for name, model in models:
kfold = model_selection.KFold(n_splits=10, random_state=seed)
cv_results = model_selection.cross_val_score(
model, X_train, Y_train, cv=kfold, scoring=scoring)
results.append(cv_results)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/linear_model/logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.
FutureWarning)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/linear_model/logistic.py:459: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.
"this warning.", FutureWarning)
I checked the versions of python on my terminal and jupyter notebook, I see that jupyter notebook has 3.6.5 version and terminal has 3.7 version.
Not sure if this is what causing the issue.
jupyter notebook:
import sys
print(sys.version)
print(sys.path)
3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
['', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/extensions', '/Users/shafeeqrahaman/.ipython']
This issue is not just with xgboost
package but happens when I try to import keras as well
First you need to install Jupyter for Python 3.7. As you can see when you run python3
in the console it comes up with Python 3.7 so that's the command you want to be using.
Installing Jupyter
Here is the documentation for reference. According to the documentation you simply just run:
python3 -m pip --upgrade pip
python3 -m pip install jupyter
Running Jupyter on Python 3.7
python3 -m pip install jupyter
Will run Jupyter, but specifically on python3
, which is bound to Python 3.7 for you.
*This is how I remember doing it but I haven't tested it right now so if something has changed this may not work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.