在Linux上若是首先安裝了python,而後在安裝sqlite3的話,在 python ‘import sqlite3' 就會報錯 python
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/linux/depot/Python-2.5/lib/python2.5/sqlite3/__init__.py", line 24, in <module> from dbapi2 import * File "/linux/depot/Python-2.5/lib/python2.5/sqlite3/dbapi2.py", line 27, in <module> from _sqlite3 import * ImportError: No module named _sqlite3
在網上查了一下,說只要從新編譯一下python,重裝一次就能夠了,因此我從新編譯安裝了一次
安裝在前面的redhat 升級python到2.7博文有提過 linux
可是編譯安裝以後仍是報錯。。。 sql
在編譯的過程當中我發現後臺報的一個錯誤: shell
Failed to build these modules:
_sqlite3
api
在網上查了一下解決辦法:編輯源碼下的connection.c這個文件
ui
vi Python-2.7.3/Modules/_sqlite/connection.c spa
在 .net
#include "cache.h"
#include "module.h"
#include "connection.h"
#include "statement.h"
#include "cursor.h"
#include "prepare_protocol.h"
#include "util.h"
#include "sqlitecompat.h" code
#include "pythread.h" sqlite
#define ACTION_FINALIZE 1
#define ACTION_RESET 2
#if SQLITE_VERSION_NUMBER >= 3003008
#ifndef SQLITE_OMIT_LOAD_EXTENSION
#define HAVE_LOAD_EXTENSION
#endif
#endif
下面添加
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 sqlite_int64;
typedef unsigned __int64 sqlite_uint64;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;
再次make,沒有報錯。
附註:
解決問題是借鑑了這個博文:
http://blog.hijiam.com/page/2