没有名为 _sqlite3 的模块
我正在尝试在我的 VPS 运行 Debian 5. 当我运行演示应用程序时,它返回此错误:
File "/usr/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py", line 30, in <module>
raise ImproperlyConfigured, "Error loading %s: %s" % (module, exc)
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
查看 Python 安装,它给出相同的错误:
Python 2.5.2 (r252:60911, May 12 2009, 07:46:31)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/lib/python2.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
>>>
在网络上阅读,我了解到 Python 2.5 应该附带所有必要的功能包含 SQLite 包装器。 我是否需要重新安装 Python,或者是否有其他方法来启动并运行该模块?
I am trying to run a Django app on my VPS running Debian 5. When I run a demo app, it comes back with this error:
File "/usr/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py", line 30, in <module>
raise ImproperlyConfigured, "Error loading %s: %s" % (module, exc)
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
Looking at the Python install, it gives the same error:
Python 2.5.2 (r252:60911, May 12 2009, 07:46:31)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/lib/python2.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
>>>
Reading on the web, I learn that Python 2.5 should come with all the necessary SQLite wrappers included. Do I need to reinstall Python, or is there another way to get this module up and running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(29)
尝试复制
_sqlite3.so
以便 Python 可以找到它。它应该很简单:
相信我,尝试一下。
Try copying
_sqlite3.so
so that Python can find it.It should be as simple as:
Trust me, try it.
您需要在 python 环境中安装 pysqlite :
You need to install pysqlite in your python environment:
下载sqlite3:
按照以下步骤安装:
Download sqlite3:
Follow these steps to install:
我解决了重新安装 Python
pyenv install
然后pyenv rehash
的问题。 不破坏任何先前创建的 virtualenvI resolved reinstalling Python
pyenv install <version>
and thenpyenv rehash
. Without destroying any previously created virtualenv我正在使用带有 Python3.9 和 venv 的 Ubuntu。 我遇到过同样的问题。
首先我安装了 pysqlite
但它安装在
/home//.local/lib/python3.9/site-packages/pysqlite3
然后我将它移动到本地目录
注意名称从
pysqlite3
更改为sqlite3
I am using Ubuntu with Python3.9 and a venv. I had the same issue.
first I installed pysqlite
but it was installed in the
/home/<user>/.local/lib/python3.9/site-packages/pysqlite3
then I moved it to the local dir
pay attention to the name change from
pysqlite3
tosqlite3
我在 NetBSD 服务器上遇到了同样的问题。 需要使用
pkgin
安装缺少的.so
文件。 为了确定要安装什么包,我运行了很多结果,包括
(以及其他 python 版本)。 我使用的是 python 3.9,因此 py39-sqlite3-3.9.13nb22 是我的正确选择。 跑步
为我解决了这个问题。
I ran into this same problem on a NetBSD server. A missing
.so
file needed to be installed usingpkgin
. To identify what package to install, I ranwhich had lots of results, including
(and other python versions as well). I'm using python 3.9, so
py39-sqlite3-3.9.13nb22
was the correct choice in my case. Runningfixed the issue for me.
我在 Ubuntu 中的 python 虚拟环境中设置时遇到了多个 python 依赖包的问题。这是因为 sqlite 绑定了我们的 python。
我遇到的错误:
我通过 --enable-loadable-sqlite-extensions=yes 解决了它
1.) 首先找到您用于创建虚拟环境的 python 或 python 版本。 我用过python3.8
例如
注意: pytho 会有很多包检查。 您将找到每个 python 版本的配置文件,现在使用特定的 python 版本
或者
现在,使用该 python 版本创建虚拟环境
例如
转到要创建虚拟环境的文件夹
已完成,现在您可以安装软件包
I faced this issue with multiple python dependent package while setup in python virtual enironment in Ubuntu.It is because of sqlite binding for our python.
Error I got:
I resolved it by --enable-loadable-sqlite-extensions=yes
1.) First find your python or python version you used for creating virtual env. I have used python3.8
e.g
Note: there will be many package check for pytho. you will find configure file for each python version, now use specific python version
OR
Now, create your virtual env using that python version
e.g
Go the folder where you want to create the virtual env
Its done, now you can install packages
如果您使用的是 FreeBSD,请尝试像这样安装 sqlite。
Try installing sqlite like this if you are using FreeBSD.
你必须是centos或者redhat并且自己编译python,
这是python的bug
在你的 python 源代码目录中执行此操作并在下面执行此操作
you must be in centos or redhat and compile python yourself,
it is python‘s bug
do this in your python source code dir and do this below
我在 FreeBSD 8.1 中遇到问题:
通过站立端口解决了 ----------
在此之后可以看到:
I have the problem in FreeBSD 8.1:
It is solved by stand the port ----------
after this one can see:
我很失望这个问题直到今天仍然存在。 由于我最近尝试在 CentOS 8.1 上安装 vCD CLI,并且在尝试运行它时遇到了相同的错误。 在我的情况下,我必须解决这个问题的方法如下:
正如我一直这样做是为了创建一个关于如何安装 vCD CLI 的不同博客文章和 VMware 容器服务扩展。 我最终捕获了用于解决问题的步骤,并将其放在单独的博客文章中:
http://www.virtualizationteam.com/cloud/running-vcd-cli-fail-with-the-following -error-modulenotfounderror-no-module-named-_sqlite3.html
我希望这有帮助,因为虽然上面的提示帮助我找到了解决方案,但我必须结合其中的一些提示并对其进行一些修改。
I was disappointed this issue still exist till today. As I have recently been trying to install vCD CLI on CentOS 8.1 and I was welcomed with the same error when tried to run it. The way I had to resolve it in my case is as follow:
As I have been doing this to create a different blogpost about how to install vCD CLI and VMware Container Service Extension. I have end up capturing the steps I used to fix the issue and put it in a separate blog post at:
http://www.virtualizationteam.com/cloud/running-vcd-cli-fail-with-the-following-error-modulenotfounderror-no-module-named-_sqlite3.html
I hope this helpful, as while the tips above had helped me get to a solution, I had to combine few of them and modify them a bit.
为登陆此页面搜索 Windows 操作系统解决方案的任何人提供答案:
如果尚未安装,则必须安装 pysqlite3 或 db-sqlite3。 您可以使用以下来安装。
对我来说,问题出在 sqlite3 的 DLL 文件上。
解决方案:
我从sqlite 站点获取了DLL 文件。 这可能会因您的情况而异
python 安装的版本。
我把它粘贴到了DLL目录中
环境。 对我来说是“C:\Anaconda\Lib\DLLs”,但请检查你的。
Putting answer for anyone who lands on this page searching for a solution for Windows OS:
You have to install pysqlite3 or db-sqlite3 if not already installed. you can use following to install.
For me the issue was with DLL file of sqlite3.
Solution:
I took DLL file from sqlite site. This might vary based on your
version of python installation.
I pasted it in the DLL directory of
the env. for me it was "C:\Anaconda\Lib\DLLs", but check for yours.
检查您的 settings.py 文件。
你不是只是为数据库引擎写了“sqlite”而不是“sqlite3”吗?
Checking your settings.py file.
Did you not just write "sqlite" instead of "sqlite3" for the database engine?
以下内容适用于具有虚拟环境的 Python 3.9:
安装 sqlite3 库。
激活Python虚拟环境。
将 sqlite3 文件复制到 Python 虚拟环境中并重命名以支持 Python 3.9。
请注意,我们将文件名中的 38 重命名为 39 以支持 Python 3.9。
The following worked for Python 3.9 with a virtual environment:
Install the sqlite3 library.
Activate the Python virtual environment.
Copy the sqlite3 file into the Python virtual environment and rename it to support Python 3.9.
Note, we're renaming 38 to 39 in the file name to support Python 3.9.
是否安装了 python-pysqlite2 软件包?
Is the python-pysqlite2 package installed?
我遇到了同样的问题,上面的答案对我没有任何作用
但现在我通过
删除 python.pip 和 sqlite3 并重新安装来
现在再次安装它
在我的情况下再次安装 sqlite3 时显示一些错误
然后我在终端上输入
来检查它是否被删除,
一旦安装了 sqlite3, 它就开始解压它
启动终端并写入
我相信这肯定会对你有帮助
i got the same problem, nothing worked for me from the above ans
but now i fixed it by
just remove python.pip and sqlite3 and reinstall
now install it again
in my case while installing sqlite3 again it showed some error
then i typed
on terminal to check if it was removed or not and it started unpacking it
once the sqlite3 is installed
fireup terminal and write
i'm sure this will definately help you
使用 asdf 安装 Python 3.8.11 后,我遇到了同样的问题
要解决此问题:
我必须安装
libsqlite3-dev
然后通过
asdf
卸载 Python并通过
asdf
再次安装 PythonI had the same problem after installing Python 3.8.11 using asdf
To fix the issue:
I had to install
libsqlite3-dev
Then uninstall Python via
asdf
And install Python again via
asdf
sqlite3
随 Python 一起提供。 我也遇到了同样的问题,我刚刚卸载了python3.6
并重新安装了它。卸载现有的python:
安装python3.6:
sqlite3
ships with Python. I also had the same problem, I just uninstalledpython3.6
and installed it again.Uninstall existing python:
Install python3.6:
这在 Redhat Centos 6.5 中对我有用:
This worked for me in Redhat Centos 6.5:
我最近尝试在 Ubuntu 11.04 桌面上安装 python 2.6.7 进行一些开发工作。 遇到了与此线程类似的问题。 我设法通过以下方式修复它:
调整 setup.py 文件以包含正确的 sqlite 开发路径。 setup.py 中的代码片段:
我添加的位是“/usr/lib/x86_64-linux-gnu/”。
运行 make 后,我没有收到任何警告,说 SQLite 支持未构建(即,它构建正确:P),但运行
make install
后,sqlite3 仍然没有导入相同的内容运行“import sqlite3”时出现“ImportError:没有名为 _sqlite3 的模块”。
因此,该库已编译,但未移动到正确的安装路径,因此我复制了
.so
文件(cp /usr/src/python/Python-2.6.7 /build/lib.linux-x86_64-2.6/_sqlite3.so /usr/local/python-2.6.7/lib/python2.6/sqlite3/
— 这些是我的构建路径,您可能需要调整 运行 make 后,瞧! SQLite3 支持现在可以使用。
I recently tried installing python 2.6.7 on my Ubuntu 11.04 desktop for some dev work. Came across similar problems to this thread. I mamaged to fix it by:
Adjusting the setup.py file to include the correct sqlite dev path. Code snippet from setup.py:
With the bit that I added being '/usr/lib/x86_64-linux-gnu/'.
After running make I did not get any warnings saying the sqlite support was not built (i.e., it built correctly :P ), but after running
make install
, sqlite3 still did not import with the same "ImportError: No module named _sqlite3" whe running "import sqlite3
".So, the library was compiled, but not moved to the correct installation path, so I copied the
.so
file (cp /usr/src/python/Python-2.6.7/build/lib.linux-x86_64-2.6/_sqlite3.so /usr/local/python-2.6.7/lib/python2.6/sqlite3/
— these are my build paths, you will probably need to adjust them to your setup).Voila! SQLite3 support now works.
我的_sqlite3.so位于/usr/lib/python2.5/lib-dynload/_sqlite3.so中。 从您的路径来看,您应该拥有文件 /usr/local/lib/python2.5/lib-dynload/_sqlite3.so。
请尝试以下操作:
如果未找到该文件,则您的 Python 安装可能有问题。 如果是,请确保其安装路径位于 Python 路径中。 在Python shell中,
在我的例子中,/usr/lib/python2.5/lib-dynload在列表中,因此它能够找到/usr/lib/python2.5/lib-dynload/_sqlite3.so。
My _sqlite3.so is in /usr/lib/python2.5/lib-dynload/_sqlite3.so. Judging from your paths, you should have the file /usr/local/lib/python2.5/lib-dynload/_sqlite3.so.
Try the following:
If the file isn't found, something may be wrong with your Python installation. If it is, make sure the path it's installed to is in the Python path. In the Python shell,
In my case, /usr/lib/python2.5/lib-dynload is in the list, so it's able to find /usr/lib/python2.5/lib-dynload/_sqlite3.so.
我发现很多人遇到这个问题是因为Python的多版本,
在我自己的vps(cent os 7 x64)上,我用这种方式解决了它:
找到文件“_sqlite3.so”
out:
/usr/lib64/python2.7/lib-dynload/_sqlite3.so
找到要使用的python标准库的目录,
对我来说
/usr/local/lib/python3.6/lib-dynload
复制文件:
最后一切就ok了。
I found lots of people meet this problem because the Multi-version Python,
on my own vps (cent os 7 x64), I solved it in this way:
Find the file "_sqlite3.so"
out:
/usr/lib64/python2.7/lib-dynload/_sqlite3.so
Find the dir of python Standard library you want to use,
for me
/usr/local/lib/python3.6/lib-dynload
Copy the file:
Finally, everything will be ok.
对于带有 Redhat 7 或 Centos 7 的 Python 3.7.8。
For Python 3.7.8 with Redhat 7 or Centos 7.
这就是我为了让它发挥作用所做的。
我正在使用安装了 python 2.7.5 的 pythonbrew(使用 pip)。
我首先按照 Zubair(上面)所说的操作并运行了这个命令:
然后我运行了这个命令:
这解决了数据库问题,当我运行时我得到了确认:
This is what I did to get it to work.
I am using pythonbrew(which is using pip) with python 2.7.5 installed.
I first did what Zubair(above) said and ran this command:
Then I ran this command:
This fixed the database problem and I got confirmation of this when I ran:
我的Python是从源代码构建的,原因是执行配置时缺少选项
python版本:3.7.4
已修复
my python is build from source, the cause is missing options when exec configure
python version:3.7.4
fixed
安装
sqlite-devel
包:yum install sqlite-devel -y
<预置><代码>./配置
制作
进行替代安装
Install the
sqlite-devel
package:yum install sqlite-devel -y
Recompile python from the source:
我遇到了同样的问题(在 Ubuntu Lucid 上从源代码构建 python2.5),并且 import sqlite3 抛出了相同的异常。 我已经从包管理器安装了 libsqlite3-dev,重新编译了 python2.5,然后导入工作了。
I had the same problem (building
python2.5
from source on Ubuntu Lucid), andimport sqlite3
threw this same exception. I've installedlibsqlite3-dev
from the package manager, recompiled python2.5, and then the import worked.在使用 pyenv 时,我在 Ubuntu 上的 Python 3.5 上遇到了同样的问题。
如果您使用 pyenv 安装 python,它会被列为 常见构建问题。 要解决此问题,请删除已安装的 python 版本,安装要求(对于这种特殊情况
libsqlite3-dev
),然后使用“Then recreate virtualenv if need”重新安装 python 版本。
I had the same problem with Python 3.5 on Ubuntu while using pyenv.
If you're installing the python using pyenv, it's listed as one of the common build problems. To solve it, remove the installed python version, install the requirements (for this particular case
libsqlite3-dev
), then reinstall the python version withThen recreate virtualenv if needed.
您的 makefile 似乎没有包含适当的
.so
文件。 您可以通过以下步骤纠正此问题:sqlite-devel
(或在某些基于 Debian 的系统上安装libsqlite3-dev
)注意
sudo make install
部分会将 python 版本设置为系统范围的标准,这可能会产生不可预见的后果。 如果您在工作站上运行此命令,您可能希望将其与现有的 python 一起安装,这可以通过sudo make altinstall
。It seems your makefile didn't include the appropriate
.so
file. You can correct this problem with the steps below:sqlite-devel
(orlibsqlite3-dev
on some Debian-based systems)./configure --enable-loadable-sqlite-extensions && make && sudo make install
Note
The
sudo make install
part will set that python version to be the system-wide standard, which can have unforseen consequences. If you run this command on your workstation, you'll probably want to have it installed alongside the existing python, which can be done withsudo make altinstall
.