本文最后更新于 1371 天前,其中的信息可能已经有所发展或是发生改变。
卸载重装了一次,又出现这个问题。初步判断是安装/使用 vmd 导致的,可能给我删了一些文件
查看报错
完整报错如下
limin@limin-deepin:~$ jupyter notebook
Traceback (most recent call last):
File "/home/limin/anaconda3/lib/python3.8/site-packages/notebook/services/sessions/sessionmanager.py", line 9, in <module>
import sqlite3
File "/home/limin/anaconda3/lib/python3.8/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/home/limin/anaconda3/lib/python3.8/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: /home/limin/anaconda3/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so: undefined symbol: sqlite3_errstr
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/limin/anaconda3/bin/jupyter-notebook", line 6, in <module>
from notebook.notebookapp import main
File "/home/limin/anaconda3/lib/python3.8/site-packages/notebook/notebookapp.py", line 83, in <module>
from .services.sessions.sessionmanager import SessionManager
File "/home/limin/anaconda3/lib/python3.8/site-packages/notebook/services/sessions/sessionmanager.py", line 12, in <module>
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
报了两个错,第一个不懂什么意思,第二个是缺少模块 pysqlite2
ImportError: /home/limin/anaconda3/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so: undefined symbol: sqlite3_errstr
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
打开这个文件
sudo gedit anaconda3/lib/python3.8/site-packages/notebook/services/sessions/sessionmanager.py
报错的地方在开头几行
try:
import sqlite3
except ImportError:
# fallback on pysqlite2 if Python was build without sqlite
from pysqlite2 import dbapi2 as sqlite3
一个 try 语句,解决方法有两个,要么解决 sqlite3,要么解决 pysqlite2
找了很多网上的方法是安装 pysqlite3,然后把文件里的 pysqlite2 改成 pysqlite3,但是我在 pip 安装的时候报了个 build 错,装完后仍然打不开
解决方法
安装 pysqlite3 的二进制包
pip install pysqlite3-binary
然后修改上述文件中的 pysqlite2 为 pysqlite3,再打开就可以正常打开了
看了下屏幕回显有新的报错
limin@limin-deepin:~$ jupyter notebook
[W 08:26:24.536 NotebookApp] 加载插件 jupyterlab 失败
Traceback (most recent call last):
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyter_server/services/sessions/sessionmanager.py", line 9, in <module>
import sqlite3
File "/home/limin/anaconda3/lib/python3.8/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/home/limin/anaconda3/lib/python3.8/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: /home/limin/anaconda3/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so: undefined symbol: sqlite3_errstr
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/limin/anaconda3/lib/python3.8/site-packages/notebook/notebookapp.py", line 2033, in init_server_extensions
mod = importlib.import_module(modulename)
File "/home/limin/anaconda3/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyterlab/__init__.py", line 7, in <module>
from .labapp import LabApp
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyterlab/labapp.py", line 15, in <module>
from jupyterlab_server import slugify, WORKSPACE_EXTENSION
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyterlab_server/__init__.py", line 4, in <module>
from .app import LabServerApp
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyterlab_server/app.py", line 7, in <module>
from jupyter_server.extension.application import ExtensionApp, ExtensionAppJinjaMixin
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyter_server/extension/application.py", line 21, in <module>
from jupyter_server.serverapp import ServerApp
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyter_server/serverapp.py", line 77, in <module>
from jupyter_server.services.sessions.sessionmanager import SessionManager
File "/home/limin/anaconda3/lib/python3.8/site-packages/jupyter_server/services/sessions/sessionmanager.py", line 12, in <module>
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
解决方法
sudo gedit /home/limin/anaconda3/lib/python3.8/site-packages/jupyter_server/services/sessions/sessionmanager.py
打开这个文件把 pysqlite2 改成 pysqlite3 就行了