我应该如何处理软件包?
我正在尝试安装 pysqlite 但遇到了麻烦。我发现最可能的原因是缺少 sqlite 标头,我必须安装它们。我的平台:CentOS 版本 5.3(最终版)。我有Python-2.6.2。
我还发现我需要 .rpm 文件。只要我有它们,我就会执行:
rpm -i sqlite3-devel-3.n.n.n.rpm
一切都应该没问题。
但是,我不知道在哪里可以找到 sqlite3-devel-3.nnnrpm 文件。它应该已经在我的系统上了吗?我无法使用“locate sqlite3-devel-3”找到它。我应该下载这个文件吗?如果是,我在哪里可以找到它以及我应该使用哪个版本?我的意思是,.rpm 文件可能应该与我计算机上的 sqlite 版本一致?如果是这样,我怎样才能找到我的sqlite版本?
如果我输入“from pysqlite2 import dbapi2 as sqlite”我得到:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pysqlite2
“yum search pysqlite”给我以下内容:
Loaded plugins: fastestmirror
Excluding Packages in global exclude
list Finished
==== Matched: pysqlite ==== python-sqlite.x86_64 : Python bindings
for sqlite.
顺便说一句,我有以下目录: /home/myname/opt/lib/python2.6/sqlite3 我有以下文件:
dbapi2.py dbapi2.pyc dbapi2.pyo
dump.py dump.pyc dump.pyo
__init__.py __init__.pyc __init__.pyo test
如果我输入“import unittest”,然后输入“import sqlite3 as sqlite”,我会得到:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myname/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import * File "/home/myname/opt/lib/python2.6/sqlite3/dbapi2.py",
line 27, in <module>
from _sqlite3 import * ImportError: No module named _sqlite3
提前谢谢您。
I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them. My platform: CentOS release 5.3 (Final). I have Python-2.6.2.
I also found out that I need .rpm files. As far as I have them I execute:
rpm -i sqlite3-devel-3.n.n.n.rpm
and everything should be fine.
However, I do not know where to find sqlite3-devel-3.n.n.n.rpm file. Should it already be on my system? I could not locate it with "locate sqlite3-devel-3". Should I download this file? If yes where I can find it and which version should I use? I mean, the .rpm file should be, probably, consistent with the version of sqlite that I have on my computer? If it is the case, how can I find out the version of my sqlite?
If I type "from pysqlite2 import dbapi2 as sqlite" I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pysqlite2
"yum search pysqlite" gives me the following:
Loaded plugins: fastestmirror
Excluding Packages in global exclude
list Finished
==== Matched: pysqlite ==== python-sqlite.x86_64 : Python bindings
for sqlite.
By the way, I have the following directory:
/home/myname/opt/lib/python2.6/sqlite3
and there I have the following files:
dbapi2.py dbapi2.pyc dbapi2.pyo
dump.py dump.pyc dump.pyo
__init__.py __init__.pyc __init__.pyo test
If I type "import unittest" and then "import sqlite3 as sqlite" I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myname/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import * File "/home/myname/opt/lib/python2.6/sqlite3/dbapi2.py",
line 27, in <module>
from _sqlite3 import * ImportError: No module named _sqlite3
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Python 2.6(和一些更早版本)包括 sqlite Python org 库引用 所以你不需要这样做。只需导入并运行
Python 2.6 (and some earlier) include sqlite Python org library ref so you should not need to do this. Just import it and run
您可以使用构建来创建项目的本地化版本。这将安装所有必需的软件包,而无需 sudo 访问服务器。
要尝试一下,请执行以下操作:
编辑 buildout.cfg 并将其替换为以下内容:
现在,运行 ./bin/buildout 来重建项目。这将下载所有必需的包并为您创建一个新的解释器,您可以使用可以访问 sqlite 的测试。
这为您提供了一个可用于内部开发的受控环境。
要了解有关构建的更多信息,您可以观看 pycon 2009 关于 Setuptools、Distutils 和 Buildout 的视频。
Python 中的鸡蛋和构建部署 - 第 1 部分
Python 中的鸡蛋和构建部署 - 第 2 部分
Python 中的鸡蛋和构建部署 - 第 3 部分
祝你好运
You can use buildout to create localized version of your project. This will install all necessary packages without having sudo access to the server.
To give it try, do the following:
edit buildout.cfg and replace it with following:
Now, run ./bin/buildout to rebuild the project. This will download all of the necessary packages and create a new interpreter for you that you can use test that you can access sqlite.
This gives you a controlled environment that you can use to develop inside of.
To learn more about buildout, you can watch videos from pycon 2009 on Setuptools, Distutils and Buildout.
Eggs and Buildout Deployment in Python - Part 1
Eggs and Buildout Deployment in Python - Part 2
Eggs and Buildout Deployment in Python - Part 3
Good luck
通常,您应该通过 yum 安装 python
sqlite
模块,例如:然后编辑代码,将
sqlite2
引用更改为sqlite3< /代码>。
顺便说一句,每当您阅读安装 sqlite3-devel-3.nnnrpm 的说明时,
n
部分都不是字面意思;它们应该被替换为指定 rpm 包版本的数字。Typically, you should install the python
sqlite
module throughyum
, something like:and then edit your code changing
sqlite2
references tosqlite3
.By the way, whenever you read directions to install
sqlite3-devel-3.n.n.n.rpm
, then
parts are not literal; they're supposed to be replaced with numbers specifying a version of the rpm package.