CentOS 的GAE实验

1:ssl模块

报错:
module’ object has no attribute ‘HTTPSHandler’

原因:Python未安装ssl模块

加载ssl,重新编译python

./configure --enable--ssl


2:_sqlite 模块

报错:

Traceback (most recent call last):
  File "main.py", line 9, in <module>
    from com.qsee.db.DbUtil import getAttackTuple, getRunStatus, runOver, alterAttackStatus,filter
  File "/root/scanAttack/com/qsee/db/DbUtil.py", line 7, in <module>
    import sqlite3, sys
  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

上面错误说明没有安装sqlite-devel,所以要先安装sqlite-devel,再编译升级python,才可以使用sqlite3库

PS:如果安装sqlite-devel后,仍无法加载_sqlite3模块,常识如下方法:

编辑源码下的connection.c这个文件

#vi Python-2.7.3/Modules/_sqlite/connection.c


#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"

#include "pythread.h"

#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,没有报错。


你可能感兴趣的:(CentOS 的GAE实验)