_sqlite.so: undefined symbol: sqlite3_stmt_readonly 问题解决

通过pip install pysqlite,

运行程序报错:

ImportError: /usr/local/python2.7/site-packages/pysqlite2/_sqlite.so: undefined symbol: sqlite3_stmt_readonly


于是nm  /usr/local/python2.7/site-packages/pysqlite2/_sqlite.so | grep sqlite3_stmt_readonly

显示:

                U sqlite3_stmt_readonly

说明_sqlite.so中的sqlite3_stmt_readonly函数要依赖其他的库。

于是ldd /usr/local/python2.7/site-packages/pysqlite2/_sqlite.so,

显示:

linux-vdso.so.1 =>  (0x00007fff467f1000)
libpython2.7.so.1.0 => /usr/local/python/lib/libpython2.7.so.1.0 (0x00007f9f8f621000)
libsqlite3.so.0 => /usr/lib64/libsqlite3.so.0 (0x00007f9f8f341000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f9f8f124000)
libc.so.6 => /lib64/libc.so.6 (0x00007f9f8ed90000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f9f8eb8b000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f9f8e988000)
libm.so.6 => /lib64/libm.so.6 (0x00007f9f8e704000)
/lib64/ld-linux-x86-64.so.2 (0x0000003941200000)

其中与sqlite相关的只有libsqlite3.so.0 库,执行nm  /usr/lib64/libsqlite3.so.0 | grep sqlite3_stmt_readonly,没有结果,说明问题出在sqlite版本上,可能当前的sqlite版本太老,没有提供sqlite3_stmt_readonly这个函数,并且查询到有文章中提到:

  • The 2.8.0 version requires a "recent" SQLite version, at least 3.7.4, which is the first version to introduce the function sqlite3_stmt_readonly, which is now required.
于是看了一下当前的sqlite版本是3.6.2,看来sqlite没有提供这个接口函数,下载最新的sqlite编译安装,再替换之前的so库,重新执行程序,问题解决


你可能感兴趣的:(Linux系统管理)