“import sqlitebck”导致“module”对象没有属性“Connection”

2024-06-28 19:06:06 发布

您现在位置:Python中文网/ 问答频道 /正文

升级到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行是:

^{pr2}$

我在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

这是表示“sqlitebck”模块的文件:

[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

编辑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'

在我看来,在这种情况下可能遇到了一个bug,但我想确定我的理解是正确的,或者我遗漏了一些东西。在

谢谢你们的时间,伙计们!在


Tags: frompybuildsrcsourceincludelinuxusr
2条回答

似乎此问题的作者已报告了问题here。在

1)下载了最新的SQLite-ver。3.21(sqlite-autoconf-3210000。焦油gz). 在

2)编译安装。在

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

3)确保在会话中链接其库,并使其包含文件('.h'文件)可用,然后重新编译“sqlitebck”版本。1.3条。在

^{pr2}$

它现在起作用了。在

[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
>>>

相关问题 更多 >