无法在Mac OS上运行jupyter(给出pysqlite2错误)

时间:2017-11-28 22:01:47

标签: python macos jupyter-notebook jupyter-lab

我在mac os sierra安装了anaconda。简单的python脚本运行正常。但是,当我尝试运行jupyter-notebook时,它会失败。

错误消息如下:

Traceback (most recent call last):
  File "/Users/poudel/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 10, in <module>
    import sqlite3
  File "/Users/poudel/anaconda3/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/Users/poudel/anaconda3/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: dlopen(/Users/poudel/anaconda3/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-darwin.so, 2): Symbol not found: _sqlite3_enable_load_extension
  Referenced from: /Users/poudel/anaconda3/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-darwin.so
  Expected in: /usr/lib/libsqlite3.dylib
 in /Users/poudel/anaconda3/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-darwin.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/poudel/anaconda3/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/Users/poudel/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 79, in <module>
    from .services.sessions.sessionmanager import SessionManager
  File "/Users/poudel/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 13, in <module>
    from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'

我检查了dylib文件,但它就在那里。这有什么不对?

Bhishan:ls /usr/lib/libsqlite3.dylib 
/usr/lib/libsqlite3.dylib*

类似的问题:

No module named _sqlite3

但他们没有解决我的问题。

2 个答案:

答案 0 :(得分:0)

你的问题很可能是由于几个python环境造成的。 检查此questionthis question也许相关。

还尝试使用conda查看所有已安装的软件包。

答案 1 :(得分:0)

我遇到了同样的问题。

对我来说,通过sqlite安装brew解决了这个问题。

brew install sqlite