如何解决ImportError:没有名为' _sqlite3'的模块没有名为' pysqlite2' python 3.5

时间:2018-03-29 06:18:47

标签: python sqlite jupyter-notebook pysqlite

jupyter

安装jupyter笔记本

Python3版

Python 3.5.2

点子列表

jupyter (1.0.0)
jupyter-client (5.2.3)
jupyter-console (5.2.0)
jupyter-core (4.4.0)

运行jupyter笔记本

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/notebook/services/sessions/sessionmanager.py", line 10, in <module>
    import sqlite3
  File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'

在处理上述异常期间,发生了另一个异常:

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.5/site-packages/notebook/notebookapp.py", line 83, in <module>
    from .services.sessions.sessionmanager import SessionManager
  File "/usr/local/lib/python3.5/site-packages/notebook/services/sessions/sessionmanager.py", line 13, in <module>
    from pysqlite2 import dbapi2 as sqlite3
ImportError: No module named 'pysqlite2'

还从No module named _sqlite3

尝试了sudo apt-get install libsqlite3-dev

如何解决上述错误?

1 个答案:

答案 0 :(得分:0)

要解决_sqlite3的导入错误,我执行了以下操作:

此后,python -c 'import _sqlite3'/usr/local/bin/python中使用备用安装成功。我相信您可以像这样从源代码安装Python3并使用它。