更改 jupyter 笔记本中的 python 版本

发布于 2025-01-11 15:52:23 字数 1070 浏览 1 评论 0原文

我通过 jupyter hub 使用 jupyter 笔记本和 jupyter 实验室。 目前jupyter识别的python版本是3.6.8。 输入图片这里的描述

我想将python版本设置为3.7.3。

服务器上安装的python版本如下。 (/usr/bin/python*) 输入图片此处描述输入图片此处的描述

jupyter Notebook 内核在 /usr/local/share/jupyter/kernels/python3/kernel.json 中设置如下,

如果将 argv 路径更改为“/usr/bin/python3”或'/usr/bin/python3.7',内核正忙,未建立连接。 TT 仅当 argv 路径为“/usr/bin/python 3.6”时,它才能正常工作。

输入图片此处描述

  • 设置代码

sudo apt-get install python3-pip

sudo pip3 install ipykernel

sudo jupyter kernelspec安装自我

I am using jupyter notebook and jupyter lab through jupyter hub.
Currently, the python version recognized by jupyter is 3.6.8.
enter image description here

I want to set the python version to 3.7.3.

The python version installed on the server is as follows. (/usr/bin/python*)
enter image description here
enter image description here

The jupyter notebook kernel is set as follows in /usr/local/share/jupyter/kernels/python3/kernel.json

If you change the argv path to '/usr/bin/python3' or '/usr/bin/python3.7', the kernel is busy and the connection is not made. TT
It works well only when argv path is '/usr/bin/python 3.6'.

enter image description here

  • Setting Code

sudo apt-get install python3-pip

sudo pip3 install ipykernel

sudo jupyter kernelspec install-self

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南街九尾狐 2025-01-18 15:52:24

正如 这篇文章 所说,您需要创建新内核和此网站展示了如何操作 它

as this post says, you need to create a new kernel and this website shows how to do it

青朷 2025-01-18 15:52:24

我通过重新安装以下软件包解决了这个问题。谢谢。

pip3 install tornado==5.1.1
pip3 install notebook==5.7.4

I solved it by reinstalling the below packages. thank you.

pip3 install tornado==5.1.1
pip3 install notebook==5.7.4
生活了然无味 2025-01-18 15:52:24

我必须将内核从 3.8 更改为 3.11

转到此位置 - ~/.local/share/jupyter/kernels/anaconda

你将看到一个 python 目录 cd pythonX

然后打开kernel.json文件,你会看到类似这样的东西

{
 "argv": [
  "python3.8",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": true
 }
}

我只是将python3.8更改为python3.11,它对我有用(我的情况下已经安装了python3.11)

{
     "argv": [
      "python3.11",
      "-m",
      "ipykernel_launcher",
      "-f",
      "{connection_file}"
     ],
     "display_name": "Python 3 (ipykernel)",
     "language": "python",
     "metadata": {
      "debugger": true
     }
    }

I had to change my kernel from 3.8 to 3.11

Go to this location - ~/.local/share/jupyter/kernels/anaconda

you will see a python directory cd pythonX

then open the kernel.json file , you will see something like this

{
 "argv": [
  "python3.8",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": true
 }
}

I simply changed python3.8 to python3.11 and it worked for me (python3.11 was already installed in my case)

{
     "argv": [
      "python3.11",
      "-m",
      "ipykernel_launcher",
      "-f",
      "{connection_file}"
     ],
     "display_name": "Python 3 (ipykernel)",
     "language": "python",
     "metadata": {
      "debugger": true
     }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文