Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3755327
  • 博文数量: 880
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 6155
  • 用 户 组: 普通用户
  • 注册时间: 2016-11-11 09:12
个人简介

To be a better coder

文章分类

全部博文(880)

文章存档

2022年(5)

2021年(60)

2020年(175)

2019年(207)

2018年(210)

2017年(142)

2016年(81)

分类: LINUX

2019-01-04 15:08:39

转载自:

摘要:使用sqlmap时遇到一个问题,需要给python安装sqlite3。记录下安装过程!

安装sqlite3

尝试使用pip安装,安装失败:

复制代码
[root@mysql1 src]# pip install sqlite3
Collecting sqlite3
  Using cached sqlite3-99.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "", line 1, in  File "/tmp/pip-build-GKbPwN/sqlite3/setup.py", line 2, in  raise RuntimeError("Package 'sqlite3' must not be downloaded from pypi")
    RuntimeError: Package 'sqlite3' must not be downloaded from pypi ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-GKbPwN/sqlite3/
复制代码

下载安装sqlite3

复制代码
[root@mysql1 src]# wget https://sqlite.org/2017/sqlite-autoconf-3190300.tar.gz [root@mysql1 src]# tar -xvf sqlite-autoconf-3190300.tar.gz 
[root@mysql1 sqlite-autoconf-3190300]# ./configure --prefix=/usr/local/lib/python2.7/dist-packages/sqlite3
[root@mysql1 sqlite-autoconf-3190300]# make && make install
安装完毕后发现导入sqlite3仍然失败,只能重装python了 >>> import sqlite3
Traceback (most recent call last):
  File "", line 1, in  File "/usr/local/lib/python2.7/sqlite3/__init__.py", line 24, in  from dbapi2 import * File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 28, in  from _sqlite3 import * ImportError: No module named _sqlite3 >>> exit()
复制代码

修改python安装源文件setup.py

复制代码
[root@mysql1 src]# tar -xvf Python-2.7.10.tgz 
[root@mysql1 src]# cd Python-2.7.10 [root@mysql1 Python-2.7.10]# vi setup.py 
搜索sqlite3找到第1105行,在其下面加入一行上面我们安装的sqlite3的路径: 1097 # We hunt for #define SQLITE_VERSION "n.n.n" 1098 # We need to find >= sqlite version 3.0.8 1099 sqlite_incdir = sqlite_libdir = None 1100 sqlite_inc_paths = [ '/usr/include', 1101 '/usr/include/sqlite', 1102 '/usr/include/sqlite3', 1103 '/usr/local/include', 1104 '/usr/local/include/sqlite', 1105 '/usr/local/include/sqlite3', 1106 '/usr/local/lib/python2.7/dist-packages/sqlite3',  #新增此行 1107 ]
保存退出。
复制代码

重新编译python2.7

[root@mysql1 Python-2.7.10]# ./configure 
[root@mysql1 Python-2.7.10]# make && make install

验证安装

检查lib文件是否生成

[root@mysql1 Python-2.7.10]# ll /usr/local/lib/python2.7/lib-dynload/_sqlite3.so -rwxr-xr-x 1 root root 243444 Aug 30 01:15 /usr/local/lib/python2.7/lib-dynload/_sqlite3.so

验证sqlite3模块导入是否成功

复制代码
[root@mysql1 Python-2.7.10]# python
Python 2.7.10 (default, Aug 30 2017, 01:14:38) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 >>> exit()
[root@mysql1 Python-2.7.10]#
阅读(3201) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~