gpt4 book ai didi

python - Jupyter 使用了错误版本的 python

转载 作者:太空宇宙 更新时间:2023-11-03 14:13:14 24 4
gpt4 key购买 nike

您好,我已经安装了 python 2.7,但没有删除 2.6。我已经在路径中添加了 2.7,也作为别名,但当我做 jupyter notebook 时,它似乎试图访问 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

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

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

我为两个版本的 python 安装了 pip。我不确定如何解决这个问题:(

最佳答案

这可能是您的 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 版本。

关于python - Jupyter 使用了错误版本的 python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35561126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com