To be a better coder
分类: LINUX
2019-01-04 15:08:39
转载自:
摘要:使用sqlmap时遇到一个问题,需要给python安装sqlite3。记录下安装过程!
[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/
[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()
[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 ] 保存退出。
[root@mysql1 Python-2.7.10]# ./configure [root@mysql1 Python-2.7.10]# make && make install
[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
[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]#