【发布时间】:2011-05-17 05:10:59
【问题描述】:
我正在尝试使用 python 2.6.4 运行 python 脚本。托管公司安装了 2.4,所以我在类似的服务器上编译了自己的 2.6.4,然后将文件移动到 ~/opt/python。那部分似乎工作正常。
无论如何,当我运行下面的脚本时,我收到了ImportError: No module named _sqlite3,但我不确定如何解决这个问题。
大多数在线线程都提到 sqlite / sqlite3 包含在 python 2.6 中 - 所以我不确定为什么这不起作用。
-jailshell-3.2$ ./pyDropboxValues.py 回溯(最近一次通话最后): 文件“./pyDropboxValues.py”,第 21 行,在 导入 sqlite3 文件“/home/myAccount/opt/lib/python2.6/sqlite3/__init__.py”,第 24 行,在 从 dbapi2 导入 * 文件“/home/myAccount/opt/lib/python2.6/sqlite3/dbapi2.py”,第 27 行,在 从 _sqlite3 导入 * ImportError: 没有名为 _sqlite3 的模块就目录结构而言,我想我已经把所有东西都设置好了。
-jailshell-3.2$ 查找 `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最后是sqlite3目录的内容:
-jailshell-3.2$ 查找“密码” /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 的答案确实很好。我需要在我正在编译的机器上安装开发包,以便将其添加到 sqlite3.so 和相关文件中。还发现答案中的链接非常有帮助。谢谢@samplebias!
【问题讨论】: