sqlite3 python2.7 和 Ubuntu 10.04(或只是 python2.6)
问题:如何让我的非系统Python2.7找到sqlite3库?
详细信息:
我运行使用 Python2.6 的 Ubuntu 10.04 LTS。
我有需要Python2.7的项目。我使用 virtualenv 的 --python=Python2.7
标志让我的项目使用它。
我安装了以下 sqlite3 东西
libsqlite3-0 - SQLite 3 共享库
libsqlite3-dev - SQLite 3 开发文件
sqlite3 - SQLite 3 的命令行界面
我可以通过 Python2.6 导入和使用 sqlite3。但是,Python2.7 就没那么幸运了。
Python 2.7.2 (default, Sep 18 2011, 19:55:45)
[GCC 4.4.3] 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.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
这就是我在机器上获得Python2.7的方式
tar xzf Python-2.7.tgz
cd Python-2.7
./configure
make
sudo make altinstall
Question: How can I get my non-system Python2.7 to find the sqlite3 libraries?
Details:
I run Ubuntu 10.04 LTS which uses Python2.6.
I have projects that require Python2.7. I use the --python=Python2.7
flags for virtualenv to have my project use that.
I have the following sqlite3 stuff installed
libsqlite3-0 - SQLite 3 shared library
libsqlite3-dev - SQLite 3 development files
sqlite3 - A command line interface for SQLite 3
I can import and use sqlite3 fine with Python2.6. But, not so lucky with Python2.7.
Python 2.7.2 (default, Sep 18 2011, 19:55:45)
[GCC 4.4.3] 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.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
This is how I got Python2.7 on the machine
tar xzf Python-2.7.tgz
cd Python-2.7
./configure
make
sudo make altinstall
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重新编译 python2.7 就可以了。
A recompile of python2.7 did the trick.