惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
D
Docker
D
DataBreaches.Net
V
Vulnerabilities – Threatpost
P
Palo Alto Networks Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
L
LINUX DO - 热门话题
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
Project Zero
Project Zero
T
Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
宝玉的分享
宝玉的分享
Stack Overflow Blog
Stack Overflow Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
Cisco Talos Blog
Cisco Talos Blog
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
The Cloudflare Blog
Know Your Adversary
Know Your Adversary
T
Tor Project blog
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
H
Help Net Security
Simon Willison's Weblog
Simon Willison's Weblog
阮一峰的网络日志
阮一峰的网络日志
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
AWS News Blog
AWS News Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
T
Troy Hunt's Blog
量子位
G
GRAHAM CLULEY
O
OpenAI News
Engineering at Meta
Engineering at Meta
博客园 - Franky
SecWiki News
SecWiki News
F
Fortinet All Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Miya's Blog

博客大修记录 (2026) 我在用什么? 记一次软件源归档导致的 CI 构建问题 Denoising Diffusion Null-Space Model 可逆神经网络 Invertible Diffusion Model 常见推理后端安装及配置 论文复现 - MAGIS 浅谈非易失内存 深度学习环境配置(一) 深度学习环境配置(二) Debian 配置 V2Ray-A Diffusion 入门 CV 基础(二) CV 基础(一) 内存体系结构 - 简述 Programming Persistent Memory 第三章笔记 地址映射与TLB CuBase 小记
Jupyter Notebook 安装及配置
Miya · 2025-04-21 · via Miya's Blog

Errors

第一个报错的库是 typing-extensions,为了避免 tensorflow 版本依赖出问题,首先尝试降级到 4.5.0,然而在配置 Jupyter Notebook 账号密码时报错。从 Jupyter 仓库检查版本后,决定从 7.3 降至 6.5.6。

因为之前的 Python 是手动编译的,这里又埋了一个坑。运行 jupyter notebook --generate-config,报错

1
2
ModuleNotFoundError: No module named '_sqlite3'
ModuleNotFoundError: No module named 'pysqlite2'

检查 dpkg -l 是安装了 sqlite3 的,问题出在构建 Python3 时缺少 libsqlite3-dev 依赖。安装 libsqlite3-dev 后重新编译安装 Python 3.10.5。

安装

安装及配置如下。

1
2
pip install notebook==6.5.6
jupyter notebook --generate-config

设置密码

1
2
3
4
5
6
7
ipython
...

In [2]: passwd()
Enter password: (jupyter)
Verify password: (jupyter)
Out[2]: 'argon...3uWz+Q'

root 旁路启动

1
jupyter notebook --allow-root  

win !

切换 Kernel

问题描述

启动 Notebook 后检查 Python 版本为 3.11.2,并非所期望的 3.10.5

1
2
3
4
5
> pip list | grep ipykernel
ipykernel 6.29.5
> jupyter kernelspec list
Available kernels:
python3 /usr/local/share/jupyter/kernels/python3

排查。

1
2
3
!python --version
import sys
print(sys.version)

其输出为

1
2
Python 3.11.2
3.10.5 (main, Dec 9 2024, 20:37:19) [GCC 11.3.0]

不一致!

为什么呢

检查了 Python 安装,发现当前是通过 alias 指定 Python 版本为 3.10.5,而 alias 的作用是定义自定义命令,在 Jupyter Notebook 中并不生效。

已经通过 echo $SHELL 检查,Jupyter Notebook 的 bash 环境和本地一致,均为 /bin/bash,做一个小测试。

在 ~/.bashrc 中写入如下内容

1
2
alias test-cmd='echo This command is for testing.'
export TEST_ENV="This environment variable is for testing."

在 Jupyter Notebook 中的结果为:

1
2
3
4
!test-cmd
!echo $TEST_ENV
/bin/bash: line 1: test-cmd: command not found
This environment variable is for testing.

可以看到,环境变量是生效的,但 alias 并不能生效。实际上,alias 只在当前 shell 有效,即便均为 /bin/bash,也是两个不同的窗口。因此会导致 !python --version 与 Kernel 的实际 Python 版本不一致。

总结

没有总结。

参考

  1. Linux 服务器 安装Jupyter notebook 并开启远程访问 - 组学大讲堂问答社区
  2. Ubuntu安装jupyter,启动出现ModuleNotFoundError: No module named ‘pysqlite2‘ 错误 - 盼小辉丶 - 博客园
  3. python中切换jupyter notebook版本_mob64ca12dc88a3的技术博客_51CTO博客
  4. python - ModuleNotFoundError: No module named ‘jupyter_server.contents’ - Stack Overflow
  5. Releases · jupyter/notebook
  6. 创建以及更换 Jupyter Notebook 内核 Python 版本_jupyter kernel 创建已经有的python 版本-CSDN博客

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Miya's Blog