Jupyter 使用了错误版本的 python [英] Jupyter using the wrong version of python

查看:25
本文介绍了Jupyter 使用了错误版本的 python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 python 2.7,但没有删除 2.6.我已将 2.7 添加到路径中并作为别名添加,但似乎当我执行 jupyter notebook 时它尝试访问 2.6

Hi I've installed python 2.7 but did not remove 2.6. i've added 2.7 to the path and also as an alias but it seems like when I do jupyter notebook it tries to access 2.6

> jupyter notebook
Traceback (most recent call last):
File "jupyter-notebook", line 7, in <module>
 from notebook.notebookapp import main
 File "/usr/lib/python2.6/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/usr/lib/python2.6/site-packages/notebook/nbextensions.py", line 226, in  <module>
from traitlets import Bool, Enum, Unicode
File "/usr/lib/python2.6/site-packages/traitlets/__init__.py", line 1, in <module>
from .traitlets import *
File "/usr/lib/python2.6/site-packages/traitlets/traitlets.py", line 1291
return {n: t for (n, t) in cls.class_traits(**metadata).items()
               ^

我的python版本好像指向2.7

My python version seems to point to 2.7

$ python --version
Python 2.7.6

以及我的 which python 似乎给出了正确的输出:

as well as my which python seems to give the right out put :

$ which python
alias python='/usr/local/bin/python2.7'
/usr/local/bin/python2.7

我为两个版本的 python 都安装了 pip.我不知道如何解决这个问题:(

I have pip installed for both versions of python. I am not sure how to fix this :(

推荐答案

这可能是您的 python kernel.json 配置中的问题.例如我的python内核位于:

It could be a problem in your python kernel.json configuration. For example my python kernel is located at:

/usr/local/share/jupyter/kernels/python/kernel.json

并包含:

    {
     "language": "python",
     "display_name": "Python 2.7",
     "argv": [
      "/usr/local/bin/python2.7",
      "-m",
      "ipykernel",
      "-f",
      "{connection_file}"
     ]
    }

确保argv部分中的路径指向正确的python版本.

Make sure that the path in argv section points to correct version of python.

这篇关于Jupyter 使用了错误版本的 python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆