Python 如何让sqlite在共享托管服务器上工作?

Python 如何让sqlite在共享托管服务器上工作?,python,linux,unix,sqlite,Python,Linux,Unix,Sqlite,我正在尝试使用Python2.6.4运行python脚本。托管公司安装了2.4,所以我在类似的服务器上编译了自己的2.6.4,然后将文件移到~/opt/python中。那部分似乎很好用 无论如何,当我运行下面的脚本时,我得到的是importorror:没有名为_sqlite3的模块,我不知道如何修复这个问题 大多数在线线程都提到Python2.6中包含sqlite/sqlite3,所以我不确定这为什么不起作用 -jailshell-3.2$ ./pyDropboxValues.py Trac

我正在尝试使用Python2.6.4运行python脚本。托管公司安装了2.4,所以我在类似的服务器上编译了自己的2.6.4,然后将文件移到~/opt/python中。那部分似乎很好用

无论如何,当我运行下面的脚本时,我得到的是
importorror:没有名为_sqlite3的模块,我不知道如何修复这个问题

大多数在线线程都提到Python2.6中包含sqlite/sqlite3,所以我不确定这为什么不起作用

-jailshell-3.2$ ./pyDropboxValues.py Traceback (most recent call last): File "./pyDropboxValues.py", line 21, in import sqlite3 File "/home/myAccount/opt/lib/python2.6/sqlite3/__init__.py", line 24, in from dbapi2 import * File "/home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in from _sqlite3 import * ImportError: No module named _sqlite3 -jailshell-3.2$./pyDropboxValues.py 回溯(最近一次呼叫最后一次): 文件“/pyDropboxValues.py”,第21行,在 导入sqlite3 文件“/home/myAccount/opt/lib/python2.6/sqlite3/_init__uuu.py”,第24行,在 从dbapi2导入* 文件“/home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.py”,第27行,在 从_sqlite3导入* ImportError:没有名为_sqlite3的模块 我想我已经把目录结构设置好了

-jailshell-3.2$ find `pwd` -type d /home/myAccount/opt /home/myAccount/opt/bin /home/myAccount/opt/include /home/myAccount/opt/include/python2.6 /home/myAccount/opt/lib /home/myAccount/opt/lib/python2.6 /home/myAccount/opt/lib/python2.6/distutils /home/myAccount/opt/lib/python2.6/distutils/command /home/myAccount/opt/lib/python2.6/distutils/tests /home/myAccount/opt/lib/python2.6/compiler /home/myAccount/opt/lib/python2.6/test /home/myAccount/opt/lib/python2.6/test/decimaltestdata /home/myAccount/opt/lib/python2.6/config /home/myAccount/opt/lib/python2.6/json /home/myAccount/opt/lib/python2.6/json/tests /home/myAccount/opt/lib/python2.6/email /home/myAccount/opt/lib/python2.6/email/test /home/myAccount/opt/lib/python2.6/email/test/data /home/myAccount/opt/lib/python2.6/email/mime /home/myAccount/opt/lib/python2.6/lib2to3 /home/myAccount/opt/lib/python2.6/lib2to3/pgen2 /home/myAccount/opt/lib/python2.6/lib2to3/fixes /home/myAccount/opt/lib/python2.6/lib2to3/tests /home/myAccount/opt/lib/python2.6/xml /home/myAccount/opt/lib/python2.6/xml/parsers /home/myAccount/opt/lib/python2.6/xml/sax /home/myAccount/opt/lib/python2.6/xml/etree /home/myAccount/opt/lib/python2.6/xml/dom /home/myAccount/opt/lib/python2.6/site-packages /home/myAccount/opt/lib/python2.6/logging /home/myAccount/opt/lib/python2.6/lib-dynload /home/myAccount/opt/lib/python2.6/sqlite3 /home/myAccount/opt/lib/python2.6/sqlite3/test /home/myAccount/opt/lib/python2.6/encodings /home/myAccount/opt/lib/python2.6/wsgiref /home/myAccount/opt/lib/python2.6/multiprocessing /home/myAccount/opt/lib/python2.6/multiprocessing/dummy /home/myAccount/opt/lib/python2.6/curses /home/myAccount/opt/lib/python2.6/bsddb /home/myAccount/opt/lib/python2.6/bsddb/test /home/myAccount/opt/lib/python2.6/idlelib /home/myAccount/opt/lib/python2.6/idlelib/Icons /home/myAccount/opt/lib/python2.6/tmp /home/myAccount/opt/lib/python2.6/lib-old /home/myAccount/opt/lib/python2.6/lib-tk /home/myAccount/opt/lib/python2.6/hotshot /home/myAccount/opt/lib/python2.6/plat-linux2 /home/myAccount/opt/lib/python2.6/ctypes /home/myAccount/opt/lib/python2.6/ctypes/test /home/myAccount/opt/lib/python2.6/ctypes/macholib /home/myAccount/opt/share /home/myAccount/opt/share/man /home/myAccount/opt/share/man/man1 -jailshell-3.2$find`pwd`-类型d /主页/我的帐户/选择 /主页/myAccount/opt/bin /主页/我的帐户/选择/包括 /主页/myAccount/opt/include/python2.6 /home/myAccount/opt/lib /home/myAccount/opt/lib/python2.6 /home/myAccount/opt/lib/python2.6/distutils /home/myAccount/opt/lib/python2.6/distutils/command /home/myAccount/opt/lib/python2.6/distutils/tests /home/myAccount/opt/lib/python2.6/compiler /home/myAccount/opt/lib/python2.6/test /home/myAccount/opt/lib/python2.6/test/decimaltestdata /home/myAccount/opt/lib/python2.6/config /home/myAccount/opt/lib/python2.6/json /home/myAccount/opt/lib/python2.6/json/tests /home/myAccount/opt/lib/python2.6/email /home/myAccount/opt/lib/python2.6/email/test /home/myAccount/opt/lib/python2.6/email/test/data /home/myAccount/opt/lib/python2.6/email/mime /home/myAccount/opt/lib/python2.6/lib2to3 /home/myAccount/opt/lib/python2.6/lib2to3/pgen2 /home/myAccount/opt/lib/python2.6/lib2to3/fixes /home/myAccount/opt/lib/python2.6/lib2to3/tests /home/myAccount/opt/lib/python2.6/xml /home/myAccount/opt/lib/python2.6/xml/parsers /home/myAccount/opt/lib/python2.6/xml/sax /home/myAccount/opt/lib/python2.6/xml/etree /home/myAccount/opt/lib/python2.6/xml/dom /home/myAccount/opt/lib/python2.6/site-packages /home/myAccount/opt/lib/python2.6/logging /home/myAccount/opt/lib/python2.6/lib-dynload /home/myAccount/opt/lib/python2.6/sqlite3 /home/myAccount/opt/lib/python2.6/sqlite3/test /home/myAccount/opt/lib/python2.6/encodings /home/myAccount/opt/lib/python2.6/wsgiref /home/myAccount/opt/lib/python2.6/multiprocessing /home/myAccount/opt/lib/python2.6/multiprocessing/dummy /home/myAccount/opt/lib/python2.6/curses /home/myAccount/opt/lib/python2.6/bsddb /home/myAccount/opt/lib/python2.6/bsddb/test /home/myAccount/opt/lib/python2.6/idlelib /home/myAccount/opt/lib/python2.6/idlelib/Icons /home/myAccount/opt/lib/python2.6/tmp /home/myAccount/opt/lib/python2.6/lib-old /home/myAccount/opt/lib/python2.6/lib-tk /home/myAccount/opt/lib/python2.6/hotshot /home/myAccount/opt/lib/python2.6/plat-linux2 /home/myAccount/opt/lib/python2.6/ctypes /home/myAccount/opt/lib/python2.6/ctypes/test /home/myAccount/opt/lib/python2.6/ctypes/macholib /主页/我的帐户/选择/共享 /主页/myAccount/opt/share/man /home/myAccount/opt/share/man/man1 最后是sqlite3目录的内容:

-jailshell-3.2$ find `pwd` /home/myAccount/opt/lib/python2.6/sqlite3 /home/myAccount/opt/lib/python2.6/sqlite3/__init__.pyo /home/myAccount/opt/lib/python2.6/sqlite3/dump.pyc /home/myAccount/opt/lib/python2.6/sqlite3/__init__.pyc /home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.pyo /home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.pyc /home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.py /home/myAccount/opt/lib/python2.6/sqlite3/dump.pyo /home/myAccount/opt/lib/python2.6/sqlite3/__init__.py /home/myAccount/opt/lib/python2.6/sqlite3/dump.py -监狱-3.2$find`pwd` /home/myAccount/opt/lib/python2.6/sqlite3 /home/myAccount/opt/lib/python2.6/sqlite3/_init__.pyo /home/myAccount/opt/lib/python2.6/sqlite3/dump.pyc /home/myAccount/opt/lib/python2.6/sqlite3/_init__.pyc /home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.pyo /home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.pyc /home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.py /home/myAccount/opt/lib/python2.6/sqlite3/dump.pyo /home/myAccount/opt/lib/python2.6/sqlite3/_init__.py /home/myAccount/opt/lib/python2.6/sqlite3/dump.py 我觉得我需要在
sqlite3
目录中添加一些东西-可能是sqlite3.so?但我不知道从哪里得到

我做错了什么?请记住,我使用的是共享主机,这意味着要在另一台服务器上安装/编译文件,然后通过服务器复制文件。谢谢!:)

更新
我只是想确认@samplebias的答案确实很好。我需要在编译的机器上安装dev包,以便将其添加到sqlite3.so和相关文件中。还发现答案中的链接非常有用。谢谢@samplebias

一般来说,首先要做的是问你的主人。SQLite没有安装(或安装正确),这似乎有点奇怪。因此,如果你问他们,他们可能会很快解决问题。

一般来说,首先要做的是问你的主人。SQLite没有安装(或安装正确),这似乎有点奇怪。因此,如果你问他们,他们很可能会很快修复它。

对于Python2.4,你需要sqlite和绑定,或者对于Python2.4,你需要sqlite和绑定,或者在
sqlite
文件夹中列出的文件都不是
\u sqlite3.pyd
python共享库。您确定在编译Python时编译了它吗?构建日志是怎么说的?我认为需要传递一个
configure
标志


或者,只需安装
sqlite
文件夹中列出的所有文件都不是
\u sqlite3.pyd
Python共享库。您确定在编译Python时编译了它吗?构建日志是怎么说的?我认为需要传递一个
configure
标志

或者,只需安装Python的构建系统,包括sqlite3。它搜索sqlite3包含和库目录的通用操作系统路径。如果未安装sqlite3开发包,Python将跳过编译
\u sqlite3.so
扩展,但仍将安装
sqlite3
包的纯Python部分

您需要有操作系统的
% ldd /usr/lib/python2.6/lib-dynload/_sqlite3.so | grep sqlite3
    libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00007f29ef3be000)
% dpkg -S /usr/lib/libsqlite3.so.0
    libsqlite3-0: /usr/lib/libsqlite3.so.0