CentOS6.5安装sqlite3

1、下载安装包:https://www.sqlite.org/download.html

2、解压

[root@mycentos ~]# tar xzvf sqlite-snapshot-201809101443.tar.gz

3、编译安装

[root@mycentos ~]# ./configure --prefix=/usr/local/sqlite3
[root@mycentos ~]# make
[root@mycentos ~]# make install

注意:安装完毕有这样一段提示

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/sqlite3/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

这段内容显示了sqlite3的安装路径:/usr/local/sqlite3/lib。
特别注意 add LIBDIR to the 'LD_LIBRARY_PATH' environment variablesqlite 建议添加环境变量。

[root@mycentos ~]# vim /etc/profile
 export LD_LIBRARY_PATH=/usr/local/sqlite3/lib
 export LD_RUN_PATH=/usr/local/sqlite3/lib

[root@mycentos ~]# source /etc/profile

4、修改python安装源码的setup.py如下:

[root@mycentos ~]# vim setup.py

sqlite_inc_paths = [ '/usr/include',
    '/usr/local/sqlite3/include', #增加该部分内容
    '/usr/include/sqlite',
    '/usr/include/sqlite3',
    '/usr/local/include',
    '/usr/local/include/sqlite',

重新编译安装Python3。

 

PS:如果运行python程序的时候会出现:ModuleNotFoundError: No module named '_sqlite3'

原因有可能是,你安装了多个python版本,而你使用的这个python版本没有_sqlite3.so这个文件。

[root@mycentos ~]# find / -name _sqlite3.so
 /usr/lib64/python2.6/lib-dynload/_sqlite3.so

然后copy到你使用的python版本相应的目录下:

[root@mycentos ~]# cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/python3/lib/python3.6/lib-dynload

问题解决!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值