"导入sqlitebck"导致"'模块'对象没有属性' Connection'"

时间:2017-11-05 11:45:32

标签: python python-2.7 sqlite

升级到sqlitebck ver后。 1.3:

Traceback (most recent call last):
  File "/opt/rh/python27/root/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/opt/rh/python27/root/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/IBM/InformationServer/Server/DSEngine/bin/ISMD-emeaprd.py/__main__.py", line 38, in <module>
AttributeError: 'module' object has no attribute 'Connection'
/var/tmp/sclPqKpVb: line 8:  2032 Segmentation fault      (core dumped) python /opt/IBM/InformationServer/Server/DSEngine/bin/ISMD-emeaprd.py

第38行是:

import sqlitebck

我已经在RHEL 6.9上编译了它 - 没有错误:

[05.11.2017] [11:13:05 GMT] root@ $ scl enable python27 bash
[root@prod-eur-isbi01 sqlitebck-1.3]# python setup.py build
running build
running build_ext
building 'sqlitebck' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I/opt/rh/python27/root/usr/include/python2.7 -c src/sqlitebck.c -o build/temp.linux-x86_64-2.7/src/sqlitebck.o
In file included from /opt/rh/python27/root/usr/include/python2.7/pyconfig.h:6,
                 from /opt/rh/python27/root/usr/include/python2.7/Python.h:8,
                 from src/sqlitebck.c:33:
/opt/rh/python27/root/usr/include/python2.7/pyconfig-64.h:1199:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/string.h:27,
                 from src/sqlitebck.c:31:
/usr/include/features.h:162:1: warning: this is the location of the previous definition
In file included from /opt/rh/python27/root/usr/include/python2.7/pyconfig.h:6,
                 from /opt/rh/python27/root/usr/include/python2.7/Python.h:8,
                 from src/sqlitebck.c:33:
/opt/rh/python27/root/usr/include/python2.7/pyconfig-64.h:1221:1: warning: "_XOPEN_SOURCE" redefined
In file included from /usr/include/string.h:27,
                 from src/sqlitebck.c:31:
/usr/include/features.h:164:1: warning: this is the location of the previous definition
creating build/lib.linux-x86_64-2.7
gcc -pthread -shared build/temp.linux-x86_64-2.7/src/sqlitebck.o -L/opt/rh/python27/root/usr/lib64 -lsqlite3 -lpython2.7 -o build/lib.linux-x86_64-2.7/sqlitebck.so

这是代表&#39; sqlitebck&#39;的文件。模块:

[root@ lib.linux-x86_64-2.7]# ll
total 28
-rwxr-xr-x 1 root root 24789 Nov  5 11:13 sqlitebck.so

安装过程也没问题:

python setup.py install
running install
running build
running build_ext
running install_lib
copying build/lib.linux-x86_64-2.7/sqlitebck.so -> /opt/rh/python27/root/usr/lib64/python2.7/site-packages
running install_egg_info
Writing /opt/rh/python27/root/usr/lib64/python2.7/site-packages/sqlitebck-1.3-py2.7.egg-info

EDIT_1:以互动模式尝试:

bash-4.1$ python
Python 2.7.13 (default, Feb  8 2017, 06:30:30)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import sqlitebck
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Connection'

在我看来,在这种情况下可能会遇到一个错误,但我想确保我的理解是正确的,或者我错过了什么。

感谢您的时间,伙计们!

2 个答案:

答案 0 :(得分:1)

似乎问题&amp;该问题的作者here已报告。

答案 1 :(得分:0)

1)下载最新的SQLite - ver。 3.21(sqlite-autoconf-3210000.tar.gz)。

2)编译并安装它。

[root@localhost sqlitebck]# sqlite3 -version
3.21.0 2017-10-24 18:55:49 1a584e499906b5c87ec7d43d4abce641fdf017c42125b083109bc77c4de48827

3)确保在会话中链接其库,并提供其INCLUDE文件(&#39; .h&#39;文件) - 然后重新编译&#39; sqlitebck&#39;版本。 1.3。

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'

现在有效。

[root@localhost sqlitebck-1.3]# python
Python 2.7.13 (default, Apr 12 2017, 06:56:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlitebck
>>>