简体   繁体   English

如何在Jupyter Notebook和终端之间匹配python版本的版本? 3.6.5至3.7

[英]How do I match version of python version between jupyter notebook and terminal? 3.6.5 to 3.7

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 我在jupyter笔记本电脑上遇到以下错误,我认为是由于笔记本电脑上存在多个版本的python,我正在尝试导入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, 运行kfold选择时,我还会收到以下警告,

# 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. 我检查了终端和jupyter笔记本上的python版本,发现jupyter笔记本具有3.6.5版本,终端具有3.7版本。

Not sure if this is what causing the issue. 不知道这是否是导致问题的原因。

在此处输入图片说明

在此处输入图片说明

jupyter notebook: jupyter笔记本:

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 这个问题不仅与xgboost软件包有关,而且在我尝试导入keras时也会发生

First you need to install Jupyter for Python 3.7. 首先,您需要为Python 3.7安装Jupyter。 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. 如您所见,当您在控制台中运行python3时,它附带了Python 3.7,这就是您要使用的命令。

Installing Jupyter 安装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 在Python 3.7上运行Jupyter
python3 -m pip install jupyter
Will run Jupyter, but specifically on python3 , which is bound to Python 3.7 for you. 将运行Jupyter,但特别是在python3上运行,它已与Python 3.7绑定。

*This is how I remember doing it but I haven't tested it right now so if something has changed this may not work. *这是我记得这样做的方式,但是我现在尚未对其进行测试,因此,如果发生了某些变化,则可能无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jupyter notebook/lab 终端 python 版本 - jupyter notebook/lab terminal python version 不同的 python 版本 Jupyter Notebook linux 终端,在 jupyter 中找不到模块,但能够在终端中找到 - Different python version Jupyter Notebook linux terminal, can't find module in jupyter, but able to do that in terminal Jupyter Notebook (myenv: 'conda') 中的 Python 版本不同的终端版本,我想更新 - Python version in Jupyter Notebook (myenv: 'conda') different terminal version and I want to update 如何创建具有特定 python 版本的 jupyter notebook? - How to create jupyter notebook with specific python version? 如何在 Jupyter 笔记本中更改 Python 版本? - How to change Python version in Jupyter notebook? 如何使用不同版本的 Python 运行 Jupyter Notebook? - How to run Jupyter Notebook with a different version of Python? 如何在 ubuntu 上将我的 python 版本从 3.7.5 降级到 3.6.5 - How do I downgrade my version of python from 3.7.5 to 3.6.5 on ubuntu Python版本和Jupyter Notebook的问题 - Problem with Python Version And Jupyter Notebook 如何升级openssl版本并将其链接到python 3.6.5 - How to upgrade openssl version and link it to python 3.6.5 尝试从终端打开 Jupyter Notebook 不断收到 zsh 错误:找不到命令:jupyter:Python 版本:2.7.16 - Trying to Open Jupyter Notebook from Terminal constantly getting error of zsh: command not found: jupyter: Python Version: 2.7.16
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM