如何获取_sqlite3.so文件?

发布于 2024-08-05 08:45:42 字数 1287 浏览 7 评论 0原文

我已经安装了Python 2.6.2..我是在“本地”安装的,因为我没有root权限。对于这个版本的Python,我想使用名为“sqlite3”的模块(在早期版本中称为“pysqlite”)。理论上,我必须能够毫无问题地使用这个模块,因为它应该默认包含在所考虑的 Python 版本中。然而,我有一些麻烦。当我输入:

from sqlite3 import *

我得到:

Traceback (most recent call last):
  File "", line 1, in File "/home/verrtex/opt/lib/python2.6/sqlite3/init.py", line 24, in
    from dbapi2 import *
  File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in
    from _sqlite3 import * 
ImportError: No module named _sqlite3

正如我已经告诉过的,这个问题的可能原因是模块尝试导入 _sqlite3 并失败,所以它没有找到 _sqlite3.so。我的“/home/verrtex/opt/lib/python2.6/lib-dynload”目录中没有 _sqlite3.so 文件,这一事实支持了这种解释。所以,这就是我必须解决的问题(我必须将此文件放到这个目录中)。

我发现要解决这个问题我必须“安装sqlite3并重新编译Python”。我还发现可以通过“从源代码构建并将库移动到 /usr/lib/python2.5/lib-dynload/”来解决该问题。

但是,我不清楚我到底应该做什么。我应该安装名为“sqlite3”的 python 模块还是应该安装 sqlite-database?顺便说一句,我已经由管理员全局安装了sqlite-database。我可以使用它还是仍然需要安装自己的数据库?顺便说一句,我没有root权限。这会是一个问题吗?或者我需要安装 python 模块?在这种情况下,缺乏 root 权限是一个问题吗?

我还被告知,从 SQLite 下载页面获取源文件,提取存档,移动到扩展目录并执行:

./configure
make
make install

然后我必须将新编译的文件复制到我的 Python 目录。我应该复制所有新编译的文件吗?我应该复制到哪个目录(我的 Python 目录有一些子目录)?

非常感谢任何帮助,因为我已经解决这个问题一段时间了。

PS 我的操作系统是 CentOS 版本 5.3(最终版)。

I have installed Python 2.6.2.. I did it "locally" since I do not have root permissions. With this version of Python I wanted to use module called "sqlite3" (it is called "pysqlite" in earlier versions). In theory I had to be able to use this module without any problems since it is supposed to be included by default in the considered version of Python. However, I have some troubles. When I type:

from sqlite3 import *

I get:

Traceback (most recent call last):
  File "", line 1, in File "/home/verrtex/opt/lib/python2.6/sqlite3/init.py", line 24, in
    from dbapi2 import *
  File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in
    from _sqlite3 import * 
ImportError: No module named _sqlite3

As I have already told to, the possible reason of this problem is that the module in tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. This explanations is supported by the fact that I do not have _sqlite3.so file in my "/home/verrtex/opt/lib/python2.6/lib-dynload" directory. So, this is the problem I have to solve (I have to get this file to this directory).

I found out that to solve this problem I have to "install sqlite3 and recompile Python". I also found out that the problem can be solved by "building from source and moving the library to /usr/lib/python2.5/lib-dynload/".

However, it is not clear to me what exactly should I do. Should I install python module called "sqlite3" or I should install sqlite-database? By the way, I have already sqlite-database installed globally by the administrator. Can I use it or I still have to install my own database? By the way, I do not have root permissions. Can it be a problem? Or I need to install a python module? Is absence of root permissions a problem, in this case?

I also has been told to, to take source files from SQLite Download Page, extract archive, move to expanded directory and execute:

./configure
make
make install

Then I have to copy newly compiled files to my Python directory. Should I copy all newly compiled files? And to which exactly directory should I copy (my Python directory have some subdirectories)?

Would very appreciate any help, because I stack with this problem for a wile.

P.S. My OS is CentOS release 5.3 (Final).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

独自←快乐 2024-08-12 08:45:42

您的 sys.path 可能没有指向您本地安装的副本,或者您没有运行您认为的 Python 2.6.2。

如果不是这种情况,您需要 SQLite 开发标头(sqlite-dev 或其他),然后重新编译 Python。您需要在编译结束时注意,因为它会抱怨由于缺少依赖项而未构建的内容。

编辑:重读问题。

编辑2:另外,不要这样做:

from module import *

这样做:

from module import what_i_need
import module2

Your sys.path is likely not pointing to your locally installed copy, or you're not running the Python 2.6.2 you think you are.

If none of that is the case, you need the SQLite development headers (sqlite-dev or whatever), and then recompile Python. You need to pay attention at the end of the compile, because it complains about what it didn't build due to missing dependencies.

EDIT: Reread question.

EDIT 2: Also, please don't do this:

from module import *

Do this:

from module import what_i_need
import module2
朱染 2024-08-12 08:45:42

尽管您可能已经找到了解决方案,但我只是为遇到同样问题的人写下了我的解决方案。

我的操作系统是CentOS 6.3(Final) with python2.6

我在系统中安装了python2.7.3,但问题仍然存在。 (_sqlite3.so 在安装了 python2.7.3 后应该位于 /path/to/python2.7.3/lib/python2.7/lib-dynload 中。因为在安装 python2.7 之前,sqlite-autoconf-3071502.tar.gz 已安装。)

然后我复制/path/to/python2.6/lib/python2.6/lib-dynload/_sqlite3.so 到 python2.7 的路径。然后输入 python-shell:

<代码>>>>导入sqlite3

<代码>>>>导入_sqlite3

无错误报告。

不幸的是,当我运行 python 脚本时,该死的错误像以前一样出现了。
我安装 sqlite-devel(sudo yum install sqlite-devel 或下载此处),然后再次重新安装python2.7.3。再次运行我的 python 脚本。谢天谢地!该死的错误终于解决了。

Although you might have found your solution, I just wrote mine down for someone who are stuck in the same problem.

My OS is CentOS 6.3(Final) with python2.6.

I install python2.7.3 in my system, but the problem's still there. (_sqlite3.so should be in /path/to/python2.7.3/lib/python2.7/lib-dynload after python2.7.3 has been installed. Because before python2.7 was installed, sqlite-autoconf-3071502.tar.gz was installed.)

I then copy the /path/to/python2.6/lib/python2.6/lib-dynload/_sqlite3.so to the python2.7's path. And type in the python-shell:

>>> import sqlite3

or

>>> import _sqlite3

No error reports.

Unfortunately, the damn error appeared as before when I run my python script.
I install sqlite-devel(sudo yum install sqlite-devel or download here), and then reinstall python2.7.3 again. Run my python script again. Thank goodness! The damn error finally solved.

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