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

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

问题描述

我已经安装了python 2.7,但没有删除2.6.我已经在路径中添加了2.7并作为别名,但是当我做jupyter笔记本时,它试图访问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

以及我的哪个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天全站免登陆