欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mac运行Jupyter Notebook显示错误:" ModuleNotFoundError: No module named 'pysqlite2' "

程序员文章站 2022-01-20 10:05:05
...

错误信息,如下:

>>>$ jupyter notebook
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 10, in <module>
    import sqlite3
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: dlopen(/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so, 2): Symbol not found: _sqlite3_enable_load_extension
  Referenced from: /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so
  Expected in: /usr/lib/libsqlite3.dylib
 in /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/usr/local/lib/python3.7/site-packages/notebook/notebookapp.py", line 86, in <module>
    from .services.sessions.sessionmanager import SessionManager
  File "/usr/local/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 13, in <module>
    from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'  # 没有所谓的“pysqlite2”模块

解决方法:

使用brew命令安装sqlite模块,提前安装Homebrew软件包管理器

brew install sqlite

运行Jupyter notebook

jupyter notebook

查看brew已安装的软件包

brew list

查看pip已安装的库、模块

pip3 list  # 适用于python3
pip list  # 适用于python2

 

相关标签: jupyter