Ubuntu安装jupyter,启动出现ModuleNotFoundError: No module named 'pysqlite2' 错误
错误描述
Ubuntu安装jupyter,过程中并未出现错误,而在启动jupyter时出现错误:
Traceback (most recent call last):
File "/home/brainiac/Program/python3.7/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 9, in <module>
import sqlite3
File "/home/brainiac/Program/python3.7/lib/python3.7/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/home/brainiac/Program/python3.7/lib/python3.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/brainiac/Program/python3.7/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
File "/home/brainiac/Program/python3.7/lib/python3.7/site-packages/notebook/notebookapp.py", line 88, in <module>
from .services.sessions.sessionmanager import SessionManager
File "/home/brainiac/Program/python3.7/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 12, in <module>
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
错误定位
构建Python3时缺少libsqlite3-dev
依赖。
因此需要安装libsqlite3-dev后,重新编译python即可解决。
解决错误
安装libsqlite3-dev
sudo apt-get install libsqlite3-dev
安装完成后,重新编译安装即可,编译过程可以参考此博文。
重新运行jupyter,运行成功
jupyter notebook
后记
Enjoy coding.