没有名为 _sqlite3 的模块

发布于 2024-07-29 23:15:58 字数 1453 浏览 8 评论 0原文

我正在尝试在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(29

梓梦 2024-08-05 23:16:23

尝试复制 _sqlite3.so 以便 Python 可以找到它。

它应该很简单:

cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/lib/python2.7/

相信我,尝试一下。

Try copying _sqlite3.so so that Python can find it.

It should be as simple as:

cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/lib/python2.7/

Trust me, try it.

百善笑为先 2024-08-05 23:16:22

您需要在 python 环境中安装 pysqlite

    $ pip install pysqlite

You need to install pysqlite in your python environment:

    $ pip install pysqlite
北城挽邺 2024-08-05 23:16:21

下载sqlite3:

wget http://www.sqlite.org/2016/sqlite-autoconf-3150000.tar.gz

按照以下步骤安装:

$tar xvfz sqlite-autoconf-3071502.tar.gz
$cd sqlite-autoconf-3071502
$./configure --prefix=/usr/local
$make install

Download sqlite3:

wget http://www.sqlite.org/2016/sqlite-autoconf-3150000.tar.gz

Follow these steps to install:

$tar xvfz sqlite-autoconf-3071502.tar.gz
$cd sqlite-autoconf-3071502
$./configure --prefix=/usr/local
$make install
故笙诉离歌 2024-08-05 23:16:20

我解决了重新安装 Python pyenv install 然后 pyenv rehash 的问题。 不破坏任何先前创建的 virtualenv

I resolved reinstalling Python pyenv install <version> and then pyenv rehash. Without destroying any previously created virtualenv

遇到 2024-08-05 23:16:20

我正在使用带有 Python3.9 和 venv 的 Ubuntu。 我遇到过同样的问题。
首先我安装了 pysqlite

pip install pysqlite3

但它安装在 /home//.local/lib/python3.9/site-packages/pysqlite3

然后我将它移动到本地目录

mv /home/<user>/.local/lib/python3.9/site-packages/pysqlite3 /usr/local/lib/python3.9/sqlite3

注意名称从 pysqlite3 更改为 sqlite3

I am using Ubuntu with Python3.9 and a venv. I had the same issue.
first I installed pysqlite

pip install pysqlite3

but it was installed in the /home/<user>/.local/lib/python3.9/site-packages/pysqlite3

then I moved it to the local dir

mv /home/<user>/.local/lib/python3.9/site-packages/pysqlite3 /usr/local/lib/python3.9/sqlite3

pay attention to the name change from pysqlite3 to sqlite3

银河中√捞星星 2024-08-05 23:16:19

我在 NetBSD 服务器上遇到了同样的问题。 需要使用 pkgin 安装缺少的 .so 文件。 为了确定要安装什么包,我运行

pkgin search sqlite

了很多结果,包括

...

py38-aiosqlite-0.17.0nb1  Async bridge to the standard sqlite3 module
py38-apsw-3.37.0nb2  Python wrapper for SQLite
py38-peewee-3.15.0   Small, expressive ORM for PostgreSQL, MySQL and SQLite
py38-sqlite3-3.8.13nb22  Built-in sqlite support for Python 2.5 and up
py39-aiosqlite-0.17.0nb1  Async bridge to the standard sqlite3 module
py39-apsw-3.37.0nb2  Python wrapper for SQLite
py39-peewee-3.15.0   Small, expressive ORM for PostgreSQL, MySQL and SQLite
py39-sqlite3-3.9.13nb22  Built-in sqlite support for Python 2.5 and up
...

(以及其他 python 版本)。 我使用的是 python 3.9,因此 py39-sqlite3-3.9.13nb22 是我的正确选择。 跑步

sudo pkgin install py39-sqlite3-3.9.13nb22

为我解决了这个问题。

I ran into this same problem on a NetBSD server. A missing .so file needed to be installed using pkgin. To identify what package to install, I ran

pkgin search sqlite

which had lots of results, including

...

py38-aiosqlite-0.17.0nb1  Async bridge to the standard sqlite3 module
py38-apsw-3.37.0nb2  Python wrapper for SQLite
py38-peewee-3.15.0   Small, expressive ORM for PostgreSQL, MySQL and SQLite
py38-sqlite3-3.8.13nb22  Built-in sqlite support for Python 2.5 and up
py39-aiosqlite-0.17.0nb1  Async bridge to the standard sqlite3 module
py39-apsw-3.37.0nb2  Python wrapper for SQLite
py39-peewee-3.15.0   Small, expressive ORM for PostgreSQL, MySQL and SQLite
py39-sqlite3-3.9.13nb22  Built-in sqlite support for Python 2.5 and up
...

(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. Running

sudo pkgin install py39-sqlite3-3.9.13nb22

fixed the issue for me.

累赘 2024-08-05 23:16:18

我在 Ubuntu 中的 python 虚拟环境中设置时遇到了多个 python 依赖包的问题。这是因为 sqlite 绑定了我们的 python

我遇到的错误

    from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'

我通过 --enable-loadable-sqlite-extensions=yes 解决了它
1.) 首先找到您用于创建虚拟环境的 python 或 python 版本。 我用过python3.8
例如

$ whereis python
python: /usr/bin/python3.6m /usr/bin/python /usr/bin/python3.8 /usr/bin/python2.7-config /usr/bin/python3.8-config  python

$ cd /usr/bin

$ls
python3.8
python3.8-config

注意: pytho 会有很多包检查。 您将找到每个 python 版本的配置文件,现在使用特定的 python 版本

ox:/usr/bin$ ./python3.8-config --enable-loadable-sqlite-extensions=yes

或者

ox:/usr/bin$ ./python3.8-config --enable-optimizations --enable-loadable-sqlite-extensions

现在,使用该 python 版本创建虚拟环境
例如
转到要创建虚拟环境的文件夹

$ python3.8 -m venv mlwen_jup_env
$ source mlwen_jup_env/bin/activate

已完成,现在您可以安装软件包

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:

    from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'

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

$ whereis python
python: /usr/bin/python3.6m /usr/bin/python /usr/bin/python3.8 /usr/bin/python2.7-config /usr/bin/python3.8-config  python

$ cd /usr/bin

$ls
python3.8
python3.8-config

Note: there will be many package check for pytho. you will find configure file for each python version, now use specific python version

ox:/usr/bin$ ./python3.8-config --enable-loadable-sqlite-extensions=yes

OR

ox:/usr/bin$ ./python3.8-config --enable-optimizations --enable-loadable-sqlite-extensions

Now, create your virtual env using that python version
e.g
Go the folder where you want to create the virtual env

$ python3.8 -m venv mlwen_jup_env
$ source mlwen_jup_env/bin/activate

Its done, now you can install packages

ˇ宁静的妩媚 2024-08-05 23:16:17

如果您使用的是 FreeBSD,请尝试像这样安装 sqlite。

pkg install py27-sqlite3-2.7.10_6

Try installing sqlite like this if you are using FreeBSD.

pkg install py27-sqlite3-2.7.10_6
幼儿园老大 2024-08-05 23:16:16

你必须是centos或者redhat并且自己编译python,
这是python的bug
在你的 python 源代码目录中执行此操作并在下面执行此操作

curl -sk https://gist.github.com/msabramo/2727063/raw/59ea097a1f4c6f114c32f7743308a061698b17fd/gistfile1.diff | patch -p1

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

curl -sk https://gist.github.com/msabramo/2727063/raw/59ea097a1f4c6f114c32f7743308a061698b17fd/gistfile1.diff | patch -p1
爱人如己 2024-08-05 23:16:16

我在 FreeBSD 8.1 中遇到问题:

- No module named _sqlite3 -

通过站立端口解决了 ----------

/usr/ports/databases/py-sqlite3

在此之后可以看到:

OK ----------
'>>>' import sqlite3 -----
'>>>' sqlite3.apilevel -----
'2.0'

I have the problem in FreeBSD 8.1:

- No module named _sqlite3 -

It is solved by stand the port ----------

/usr/ports/databases/py-sqlite3

after this one can see:

OK ----------
'>>>' import sqlite3 -----
'>>>' sqlite3.apilevel -----
'2.0'
記柔刀 2024-08-05 23:16:15

我很失望这个问题直到今天仍然存在。 由于我最近尝试在 CentOS 8.1 上安装 vCD CLI,并且在尝试运行它时遇到了相同的错误。 在我的情况下,我必须解决这个问题的方法如下:

  • 使用正确的前缀从头开始安装 SQLite3
  • 清理我的 Python 安装
  • 运行 Make install 来重新安装 Python

正如我一直这样做是为了创建一个关于如何安装 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:

  • Install SQLite3 from scratch with the proper prefix
  • Make clean my Python Installation
  • Run Make install to reinstall Python

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.

一杆小烟枪 2024-08-05 23:16:14

为登陆此页面搜索 Windows 操作系统解决方案的任何人提供答案:

如果尚未安装,则必须安装 pysqlite3 或 db-sqlite3。 您可以使用以下来安装。

  • pip install pysqlite3
  • pip install db-sqlite3

对我来说,问题出在 sqlite3 的 DLL 文件上。

解决方案:

  1. 我从sqlite 站点获取了DLL 文件。 这可能会因您的情况而异
    python 安装的版本。

  2. 我把它粘贴到了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.

  • pip install pysqlite3
  • pip install db-sqlite3

For me the issue was with DLL file of sqlite3.

Solution:

  1. I took DLL file from sqlite site. This might vary based on your
    version of python installation.

  2. I pasted it in the DLL directory of
    the env. for me it was "C:\Anaconda\Lib\DLLs", but check for yours.
    Before and After placing DLL file

喜你已久 2024-08-05 23:16:13

检查您的 settings.py 文件。
你不是只是为数据库引擎写了“sqlite”而不是“sqlite3”吗?

Checking your settings.py file.
Did you not just write "sqlite" instead of "sqlite3" for the database engine?

尾戒 2024-08-05 23:16:13

以下内容适用于具有虚拟环境的 Python 3.9:

  1. 安装 sqlite3 库。

    sudo apt-get install libsqlite3-dev 
      
  2. 激活Python虚拟环境。

    源 env/bin/activate 
      
  3. 将 sqlite3 文件复制到 Python 虚拟环境中并重命名以支持 Python 3.9。

    cp /usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so ./env/lib/python3 .9/站点包 
      mv ./env/lib/python3.9/site-packages/_sqlite3.cpython-38-x86_64-linux-gnu.so ./env/lib/python3.9/site-packages/_sqlite3.cpython-39-x86_64- linux-gnu.so 
      

请注意,我们将文件名中的 38 重命名为 39 以支持 Python 3.9。

The following worked for Python 3.9 with a virtual environment:

  1. Install the sqlite3 library.

    sudo apt-get install libsqlite3-dev
    
  2. Activate the Python virtual environment.

    source env/bin/activate
    
  3. Copy the sqlite3 file into the Python virtual environment and rename it to support Python 3.9.

    cp /usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so ./env/lib/python3.9/site-packages
    mv ./env/lib/python3.9/site-packages/_sqlite3.cpython-38-x86_64-linux-gnu.so ./env/lib/python3.9/site-packages/_sqlite3.cpython-39-x86_64-linux-gnu.so
    

Note, we're renaming 38 to 39 in the file name to support Python 3.9.

最舍不得你 2024-08-05 23:16:12

是否安装了 python-pysqlite2 软件包?

sudo apt-get install python-pysqlite2

Is the python-pysqlite2 package installed?

sudo apt-get install python-pysqlite2
我恋#小黄人 2024-08-05 23:16:11

我遇到了同样的问题,上面的答案对我没有任何作用
但现在我通过

删除 python.pip 和 sqlite3 并重新安装来

  1. 修复它sudo apt-get remove python.pip
  2. sudo apt-get remove sqlite3

现在再次安装它

  1. sudo apt-get install python.pip
  2. sudo apt-get install sqlite3

在我的情况下再次安装 sqlite3 时显示一些错误
然后我在终端上输入

  1. sqlite3

来检查它是否被删除,

一旦安装了 sqlite3, 它就开始解压它
启动终端并写入

  1. sqlite3
  2. database.db (创建数据库)
    我相信这肯定会对你有帮助

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

  1. sudo apt-get remove python.pip
  2. sudo apt-get remove sqlite3

now install it again

  1. sudo apt-get install python.pip
  2. sudo apt-get install sqlite3

in my case while installing sqlite3 again it showed some error
then i typed

  1. sqlite3

on terminal to check if it was removed or not and it started unpacking it

once the sqlite3 is installed
fireup terminal and write

  1. sqlite3
  2. database.db (to create a database)
    i'm sure this will definately help you
万人眼中万个我 2024-08-05 23:16:11

使用 asdf 安装 Python 3.8.11 后,我遇到了同样的问题

要解决此问题:

我必须安装 libsqlite3-dev

sudo apt-get install libsqlite3-dev

然后通过 asdf 卸载 Python

asdf uninstall python 3.8.11

并通过 asdf 再次安装 Python

asdf install python 3.8.11

I had the same problem after installing Python 3.8.11 using asdf

To fix the issue:

I had to install libsqlite3-dev

sudo apt-get install libsqlite3-dev

Then uninstall Python via asdf

asdf uninstall python 3.8.11

And install Python again via asdf

asdf install python 3.8.11
葬シ愛 2024-08-05 23:16:10

sqlite3 随 Python 一起提供。 我也遇到了同样的问题,我刚刚卸载了python3.6并重新安装了它。

卸载现有的python:

sudo apt-get remove --purge python3.6

安装python3.6:

sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xvf Python-3.6.0.tar.xz
cd Python-3.6.0/
./configure
sudo make altinstall

sqlite3 ships with Python. I also had the same problem, I just uninstalled python3.6 and installed it again.

Uninstall existing python:

sudo apt-get remove --purge python3.6

Install python3.6:

sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xvf Python-3.6.0.tar.xz
cd Python-3.6.0/
./configure
sudo make altinstall
香橙ぽ 2024-08-05 23:16:09

这在 Redhat Centos 6.5 中对我有用:

yum install sqlite-devel
pip install pysqlite

This worked for me in Redhat Centos 6.5:

yum install sqlite-devel
pip install pysqlite
歌入人心 2024-08-05 23:16:08

我最近尝试在 Ubuntu 11.04 桌面上安装 python 2.6.7 进行一些开发工作。 遇到了与此线程类似的问题。 我设法通过以下方式修复它:

  1. 调整 setup.py 文件以包含正确的 sqlite 开发路径。 setup.py 中的代码片段:

    def sqlite_incdir: 
      sqlite_dirs_to_check = [ 
      os.path.join(sqlite_incdir, '..', 'lib64'), 
      os.path.join(sqlite_incdir, '..', 'lib'), 
      os.path.join(sqlite_incdir, '..', '..', 'lib64'), 
      os.path.join(sqlite_incdir, '..', '..', 'lib'), 
      '/usr/lib/x86_64-linux-gnu/' 
      ] 
      

    我添加的位是“/usr/lib/x86_64-linux-gnu/”。

  2. 运行 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:

  1. Adjusting the setup.py file to include the correct sqlite dev path. Code snippet from setup.py:

    def sqlite_incdir:
    sqlite_dirs_to_check = [
    os.path.join(sqlite_incdir, '..', 'lib64'),
    os.path.join(sqlite_incdir, '..', 'lib'),
    os.path.join(sqlite_incdir, '..', '..', 'lib64'),
    os.path.join(sqlite_incdir, '..', '..', 'lib'),
    '/usr/lib/x86_64-linux-gnu/'
    ]
    

    With the bit that I added being '/usr/lib/x86_64-linux-gnu/'.

  2. 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.

世态炎凉 2024-08-05 23:16:07

我的_sqlite3.so位于/usr/lib/python2.5/lib-dynload/_sqlite3.so中。 从您的路径来看,您应该拥有文件 /usr/local/lib/python2.5/lib-dynload/_sqlite3.so。

请尝试以下操作:

find /usr/local -name _sqlite3.so

如果未找到该文件,则您的 Python 安装可能有问题。 如果是,请确保其安装路径位于 Python 路径中。 在Python shell中,

import sys
print sys.path

在我的例子中,/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:

find /usr/local -name _sqlite3.so

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,

import sys
print sys.path

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.

掐死时间 2024-08-05 23:16:07

我发现很多人遇到这个问题是因为Python的多版本,
在我自己的vps(cent os 7 x64)上,我用这种方式解决了它:

  1. 找到文件“_sqlite3.so”

    find / -name _sqlite3.so 
      

    out: /usr/lib64/python2.7/lib-dynload/_sqlite3.so

  2. 找到要使用的python标准库的目录,

    对我来说 /usr/local/lib/python3.6/lib-dynload

  3. 复制文件:

    cp /usr/lib64/python2.7/lib-dynload/_sqlite3.so /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:

  1. Find the file "_sqlite3.so"

    find / -name _sqlite3.so
    

    out: /usr/lib64/python2.7/lib-dynload/_sqlite3.so

  2. Find the dir of python Standard library you want to use,

    for me /usr/local/lib/python3.6/lib-dynload

  3. Copy the file:

    cp   /usr/lib64/python2.7/lib-dynload/_sqlite3.so /usr/local/lib/python3.6/lib-dynload
    

Finally, everything will be ok.

瑕疵 2024-08-05 23:16:06

对于带有 Redhat 7 或 Centos 7 的 Python 3.7.8。

  • 安装 sqlite-devel
$ yum install sqlite-devel
  • 编译并安装带有 sqllite 扩展的 Python3
$ ./configure --enable-optimizations --enable-loadable-sqlite-extensions
$ make install

For Python 3.7.8 with Redhat 7 or Centos 7.

  • Install sqlite-devel
$ yum install sqlite-devel
  • Compile and install Python3 with sqllite extensions
$ ./configure --enable-optimizations --enable-loadable-sqlite-extensions
$ make install
雪化雨蝶 2024-08-05 23:16:05

这就是我为了让它发挥作用所做的。

我正在使用安装了 python 2.7.5 的 pythonbrew(使用 pip)。

我首先按照 Zubair(上面)所说的操作并运行了这个命令:

sudo apt-get install libsqlite3-dev

然后我运行了这个命令:

pip install pysqlite

这解决了数据库问题,当我运行时我得到了确认:

python manager.py syncdb

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:

sudo apt-get install libsqlite3-dev

Then I ran this command:

pip install pysqlite

This fixed the database problem and I got confirmation of this when I ran:

python manager.py syncdb
似最初 2024-08-05 23:16:04

我的Python是从源代码构建的,原因是执行配置时缺少选项
python版本:3.7.4

./configure --enable-loadable-sqlite-extensions --enable-optimizations
make
make install

已修复

my python is build from source, the cause is missing options when exec configure
python version:3.7.4

./configure --enable-loadable-sqlite-extensions --enable-optimizations
make
make install

fixed

鹿童谣 2024-08-05 23:16:04
  1. 安装sqlite-devel包:

    yum install sqlite-devel -y

  2. < p>从源代码重新编译 python:

    <预置><代码>./配置
    制作
    进行替代安装

  1. Install the sqlite-devel package:

    yum install sqlite-devel -y

  2. Recompile python from the source:

    ./configure
    make
    make altinstall
    
青春有你 2024-08-05 23:16:03

我遇到了同样的问题(在 Ubuntu Lucid 上从源代码构建 python2.5),并且 import sqlite3 抛出了相同的异常。 我已经从包管理器安装了 libsqlite3-dev,重新编译了 python2.5,然后导入工作了。

I had the same problem (building python2.5 from source on Ubuntu Lucid), and import sqlite3 threw this same exception. I've installed libsqlite3-dev from the package manager, recompiled python2.5, and then the import worked.

十六岁半 2024-08-05 23:16:03

在使用 pyenv 时,我在 Ubuntu 上的 Python 3.5 上遇到了同样的问题。

如果您使用 pyenv 安装 python,它会被列为 常见构建问题。 要解决此问题,请删除已安装的 python 版本,安装要求(对于这种特殊情况 libsqlite3-dev),然后使用“

pyenv install <python-version> 

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 with

pyenv install <python-version> 

Then recreate virtualenv if needed.

鹤舞 2024-08-05 23:16:00

您的 makefile 似乎没有包含适当的 .so 文件。 您可以通过以下步骤纠正此问题:

  1. 安装 sqlite-devel (或在某些基于 Debian 的系统上安装 libsqlite3-dev
  2. 使用 < 重新配置并重新编译 Python代码>./configure --enable-loadable-sqlite-extensions && 制作&& sudo make install

注意

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:

  1. Install sqlite-devel (or libsqlite3-dev on some Debian-based systems)
  2. Re-configure and re-compiled Python with ./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 with sudo make altinstall.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文