ModuleNotFoundError:为Spyder 6.0 IPython控制台安装spyder-kernels 3后没有名为“_sqlite3”的模块

问题描述 投票:0回答:1

我正在尝试在 Ubuntu 24.04 上使用 Spyder 6 IDE。安装 Spyder 6 后,我将默认的 python 解释器更改为运行 Python 3.11 的虚拟环境,并安装了spyder-kernels==3.0,以便在 IDE 中使用 python 控制台。但是,我没有显示 python 控制台,而是收到以下错误:

Traceback (most recent call last):
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/console/__main__.py", line 24, in
start.main()
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/console/start.py", line 151, in main
import_spydercustomize()
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/console/start.py", line 41, in import_spydercustomize
import spydercustomize # noqa
^^^^^^^^^^^^^^^^^^^^^^
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/customize/spydercustomize.py", line 19, in
from spyder_kernels.customize.spyderpdb import SpyderPdb
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/customize/spyderpdb.py", line 22, in
from IPython.core.autocall import ZMQExitAutocall
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/__init__.py", line 55, in
from .terminal.embed import embed
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/terminal/embed.py", line 15, in
from IPython.core.interactiveshell import DummyMod, InteractiveShell
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/core/interactiveshell.py", line 110, in
from IPython.core.history import HistoryManager
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/core/history.py", line 10, in
import sqlite3
File "/home/katmatzidis/.pyenv/versions/3.11.10/lib/python3.11/sqlite3/__init__.py", line 57, in
from sqlite3.dbapi2 import *
File "/home/katmatzidis/.pyenv/versions/3.11.10/lib/python3.11/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
Traceback (most recent call last):
File "/home/katmatzidis/.pyenv/versions/3.11.10/lib/python3.11/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/katmatzidis/.pyenv/versions/3.11.10/lib/python3.11/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/console/__main__.py", line 24, in
start.main()
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/console/start.py", line 151, in main
import_spydercustomize()
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/console/start.py", line 41, in import_spydercustomize
import spydercustomize # noqa
^^^^^^^^^^^^^^^^^^^^^^
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/customize/spydercustomize.py", line 19, in
from spyder_kernels.customize.spyderpdb import SpyderPdb
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/spyder_kernels/customize/spyderpdb.py", line 22, in
from IPython.core.autocall import ZMQExitAutocall
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/__init__.py", line 55, in
from .terminal.embed import embed
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/terminal/embed.py", line 15, in
from IPython.core.interactiveshell import DummyMod, InteractiveShell
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/core/interactiveshell.py", line 110, in
from IPython.core.history import HistoryManager
File "/home/katmatzidis/.virtualenvs/r‑tensorflow/lib/python3.11/site‑packages/IPython/core/history.py", line 10, in
import sqlite3
File "/home/katmatzidis/.pyenv/versions/3.11.10/lib/python3.11/sqlite3/__init__.py", line 57, in
from sqlite3.dbapi2 import *
File "/home/katmatzidis/.pyenv/versions/3.11.10/lib/python3.11/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

这个 sqlite3 包是什么?我的 python 虚拟环境中似乎没有它。如何安装?

我尝试通过从 Ubuntu 终端运行以下命令来安装 sqlite3 软件包:

~$ .virtualenvs/r-tensorflow/bin/pip install sqlite3

但是,pip 找不到这样的包。在网上研究问题后,我还尝试了其他变体,例如

$ .virtualenvs/r-tensorflow/bin/pip install libsqlite3-dev

但同样的问题仍然存在。我做错了什么? Spyder 6 自带的默认 python 版本(内部 python)在 IPython 控制台运行良好,但我的虚拟环境 python 出现上述错误。

我实际上发现sqlite3是在我的python虚拟环境的site-packages中埋藏的

Ubuntu\home\katmatzidis\.virtualenvs\r-tensorflow\lib\python3.11\site-packages\jedi\third_party\django-stubs\django-stubs\db\backends\sqlite3

现在我绝对不确定为什么它不起作用。我感谢您的帮助!

spyder python-3.11 sqlite3-python ubuntu-24.04
1个回答
0
投票

事实证明,我在位于 /home/katmatzidis/.pyenv/versions/3.11.10/lib/python3.11/lib-dynload 的

lib-dynload
库中丢失了一个名为 _sqlite3.cpython-311-x86_64-linux-gnu.so 的文件。这就是错误的含义
ModuleNotFoundError: No module named '_sqlite3'.
我从位于 /home/katmatzidis/spyder-6/envs/spyder-runtime/lib/python3.11/lib-dynload 的 Spyder6 内部 python 文件中找到了该文件的副本并复制它到我的 lib-dynload 库和 IPython 控制台,它工作了。

© www.soinside.com 2019 - 2024. All rights reserved.