CentOS6.5安装sqlite3[转]

Posted 小白2510

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6.5安装sqlite3[转]相关的知识,希望对你有一定的参考价值。

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

2、解压

[[email protected] ~]# tar xzvf sqlite-snapshot-201809101443.tar.gz

3、编译安装

进入 sqlite-snaspshot-20180901443目录

[[email protected] ~]# ./configure --prefix=/usr/local/sqlite3
[[email protected] ~]# make
[[email protected] ~]# 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 建议添加环境变量。

[[email protected] ~]# vim /etc/profile
 export LD_LIBRARY_PATH=/usr/local/sqlite3/lib
 export LD_RUN_PATH=/usr/local/sqlite3/lib

[[email protected] ~]# source /etc/profile

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

技术分享图片
[[email protected] ~]# 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这个文件。

[[email protected] ~]# find / -name _sqlite3.so
 /usr/lib64/python2.6/lib-dynload/_sqlite3.so

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

[[email protected] ~]# cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/python3/lib/python3.6/lib-dynload

问题解决!


以上是关于CentOS6.5安装sqlite3[转]的主要内容,如果未能解决你的问题,请参考以下文章

CentOS6.5 安装配置mysql(转)

Centos6.5中如何用sqlite3命令打开’.db’后缀的数据库执行sql

centos6.5 源码安装gcc-4.8.5(转)

linux centos6.5 php5.6 安装PHPUnit 5.2.9 (转)

(转)运维老鸟教你安装centos6.5如何选择安装包

CentOS6.5安装指定的PHP版本(php5.5)(转)