在 Linux 上以用户身份使用完整的 Sqlite3 构建 Python 2.5 [英] Building Python 2.5 with full Sqlite3 as a user on linux

查看:59
本文介绍了在 Linux 上以用户身份使用完整的 Sqlite3 构建 Python 2.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有点复杂,至少对我来说是这样.就是这样:

This is a bit of a complex problem, at least for me. Here it goes:

我在 linux 服务器上以用户身份工作,可以肯定的是,安装任何尚未安装的软件包都是不可能的.

I'm working as a user on linux server and it's safe to assume that installing any package not already installed is simply impossible.

此外,我需要使用可运行的 SQLite3 库(未安装任何形式的 Sqlite)来设置可运行的 Python 2.5(未安装).

Also I need to set up working Python 2.5 (not installed) with working SQLite3 library (Sqlite in any form not installed).

我能做的是:1. 编译 Python 2.5 并使其工作2.编译SQLite3的合并

What I can do is: 1. Compile Python 2.5 and make it work 2. Compile amalgamation of SQLite3

无论如何 - Python 2.5 应该与内置的 Sqlite3 (pysqlite) 进行交互.这似乎是正确的,但是导入 sqlite3:导入 sqlite3失败,因为 - 最后 - 无法导入 _sqlite3

Anyway - Python 2.5 is supposed to have interaction with Sqlite3 built-in (pysqlite). It seems true enough, however importing sqlite3: import sqlite3 fails because - in the end - it is impossible to import _sqlite3

一些谷歌搜索让我明白虽然 pysqlite 可能是内置的,但 sqlite 不是.因此我假设我需要在本地构建 sqlite 并以某种方式使这两个软件交互.

Some googling lead me to understand that while pysqlite may be built-in, the sqlite is not. Therefore I assumed that I need to built in locally sqlite and somehow make these two pieces of software interact.

很公平.

我能够 - 我希望如此 - 将合并编译为共享对象,但它看起来很混乱.我应该将 sqlite3.so 重命名为 _sqlite3 并将其扔到某个地方吗?看起来有点可疑,我还是尝试了,但出现错误:动态模块没有定义init函数(init_sqlite3)

I'm able to - I hope so - compile amalgamation to shared object but it seems messy. Should I rename sqlite3.so to _sqlite3 and throw it somewhere? It seems fishy a bit, I tried it anyway and get an error: dynamic module does not define init function (init_sqlite3)

在这一点上我有点卡住了.我对构建/编译的东西不太熟悉 - 我承认 sudo apt-get/sudo yum 让我很懒,但由于某种原因,目前它不是一个选择.

At this point I'm a bit stuck. I'm not too familiar with building/compiling stuff - I admit that sudo apt-get / sudo yum made me lazy but for some reason it is not an option at the moment.

感谢帮助!

推荐答案

首先使用 --prefix 下载、构建和安装 sqlite3.然后用相同的前缀构建python,它会找到sqlite安装并构建_sqlite3模块.

First download, build and install sqlite3 with a --prefix. Then build python with same prefix , it will find sqlite installation and will build _sqlite3 module.

$ mkdir -p ~/applications/src
$ cd ~/applications/src
$ wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz
$ tar xvvf sqlite-autoconf-3070900.tar.gz
$ cd sqlite-autoconf-3070900
$ ./configure --prefix=~/applications
$ make
$ make install

$ cd ~/applications/src
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
$ tar xvvf Python-2.5.2.tgz
$ cd Python-2.5.2
$ ./configure --prefix=~/applications
$ make
$ make install

$ ~/applications/bin/python
>>> import sqlite3
>>> # no error!

这篇关于在 Linux 上以用户身份使用完整的 Sqlite3 构建 Python 2.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆