您好我安装了python 2.7但没有删除2.6。我已经添加了2.7的路径,也作为别名,但似乎当我做jupyter笔记本,它试图访问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
$ python --version
Python 2.7.6
以及我的哪个python似乎给出了正确的结果:
$ which python
alias python='/usr/local/bin/python2.7'
/usr/local/bin/python2.7
我为两个版本的python安装了pip。我不知道如何解决这个问题:(
答案 0 :(得分:4)
这可能是你的python kernel.json配置中的一个问题。例如,我的python内核位于:
/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版本。
答案 1 :(得分:1)
看起来您安装了jupyter作为/usr/lib/python2.6
的扩展名。如果是这样,你必须卸载jupyter并重新安装到你想要的python中。