当我在本地(Windows)安装ibm_db模块时,它工作正常。但是当我试图在我的Gitlab项目(Linux)中安装ibm_db模块时,它失败了。首先,我必须手动下载db2驱动程序,将其解压缩到一个文件夹并将“IBM_DB_HOME”变量设置到该文件夹。我这样做了,但现在我得到了另一个错误。下面是日志。
$ python --version
Python 3.11.2
$ pip --version
pip 23.0.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
$ cp -R db2driver ~/
$ ls -l ~/db2driver/clidriver
total 44
drwxr-xr-x 2 root root 4096 Apr 4 08:25 bin
drwxr-xr-x 2 root root 4096 Apr 4 08:25 bnd
drwxr-xr-x 2 root root 4096 Apr 4 08:25 cfg
drwxr-xr-x 2 root root 4096 Apr 4 08:25 cfgcache
drwxr-xr-x 4 root root 4096 Apr 4 08:25 conv
drwxr-xr-x 2 root root 4096 Apr 4 08:25 include
drwxr-xr-x 3 root root 4096 Apr 4 08:25 lib
drwxr-xr-x 3 root root 4096 Apr 4 08:25 license
drwxr-xr-x 3 root root 4096 Apr 4 08:25 msg
drwxr-xr-x 3 root root 4096 Apr 4 08:25 properties
drwxr-xr-x 3 root root 4096 Apr 4 08:25 security64
$ export IBM_DB_HOME=~/db2driver/clidriver
$ pip install ibm_db==3.1.4
Looking in indexes: https://our.repo/artifactory/api/pypi/pypi-repo/simple
Collecting ibm_db==3.1.4
Downloading https://our.repo/artifactory/api/pypi/pypi-repo/packages/packages/a5/fa/0a8e250b54b6479304f6af2784b94fecafe6954fd3d3daedc0a3c2c1b262/ibm_db-3.1.4.tar.gz (1.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 42.9 MB/s eta 0:00:00
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: ibm_db
Building wheel for ibm_db (pyproject.toml): started
Building wheel for ibm_db (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
× Building wheel for ibm_db (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [625 lines of output]
<string>:421: UserWarning: Detected usage of IBM Data Server Driver package. Ensure you have downloaded 64-bit package of IBM_Data_Server_Driver and retry the ibm_db module install
Detected 64-bit Python
Pre-requisite check [gcc] : Passed
Pre-requisite check [Python.h] : Passed
running bdist_wheel
running build
running build_py
creating build/lib.linux-x86_64-cpython-311
copying ibm_db_dbi.py -> build/lib.linux-x86_64-cpython-311
copying testfunctions.py -> build/lib.linux-x86_64-cpython-311
copying ibmdb_tests.py -> build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/ibm_db_dlls
copying ibm_db_dlls/__init__.py -> build/lib.linux-x86_64-cpython-311/ibm_db_dlls
creating build/lib.linux-x86_64-cpython-311/certs
copying certs/__init__.py -> build/lib.linux-x86_64-cpython-311/certs
creating build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_159a_FetchAssocSeveralRows_02.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_047_FetchTupleMany_06.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_035_FetchRow_01.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_051_SetAutocommit_01.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_booleanInsertSelect.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_146a_CallSPINAndOUT_Blob_Param.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_recreateDB.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_008_ColumnInfo.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/test_232_FieldTypePosName.py -> build/lib.linux-x86_64-cpython-
...
...
...
copying ibm_db_tests/test_142_BindParamSelectStmtMultipleParams_02.py -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
running egg_info
writing ibm_db.egg-info/PKG-INFO
writing dependency_links to ibm_db.egg-info/dependency_links.txt
writing top-level names to ibm_db.egg-info/top_level.txt
reading manifest file 'ibm_db.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'clidriver'
warning: no previously-included files found matching 'config.py'
adding license file 'LICENSE'
writing manifest file 'ibm_db.egg-info/SOURCES.txt'
copying ibm_db_dlls/ibm_db.dll -> build/lib.linux-x86_64-cpython-311/ibm_db_dlls
copying certs/ibm_certs.pem -> build/lib.linux-x86_64-cpython-311/certs
copying ibm_db_tests/pic1.jpg -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/pic1_out.jpg -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/spook.png -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
copying ibm_db_tests/spook_out.png -> build/lib.linux-x86_64-cpython-311/ibm_db_tests
running build_ext
building 'ibm_db' extension
creating build/temp.linux-x86_64-cpython-311
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/root/db2driver/clidriver/include -I/usr/local/include/python3.11 -c ibm_db.c -o build/temp.linux-x86_64-cpython-311/ibm_db.o
ibm_db.c: In function ‘_python_ibm_db_free_result_struct’:
ibm_db.c:385:35: warning: unused variable ‘prev_ptr’ [-Wunused-variable]
385 | param_node *curr_ptr = NULL, *prev_ptr = NULL;
| ^~~~~~~~
ibm_db.c:385:17: warning: unused variable ‘curr_ptr’ [-Wunused-variable]
385 | param_node *curr_ptr = NULL, *prev_ptr = NULL;
| ^~~~~~~~
...
...
...
ibm_db.c:9217:40: warning: ‘%s’ directive writing up to 1039 bytes into a region of size 1024 [-Wformat-overflow=]
9217 | sprintf(error, "Fetch Failure: %s", IBM_DB_G(__python_stmt_err_msg));
| ^~
ibm_db.c:9217:9: note: ‘sprintf’ output between 16 and 1055 bytes into a destination of size 1039
9217 | sprintf(error, "Fetch Failure: %s", IBM_DB_G(__python_stmt_err_msg));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ibm_db.c:9434:61: warning: ‘%s’ directive writing up to 1039 bytes into a region of size 1019 [-Wformat-overflow=]
9434 | sprintf(error, "Failed to LOB Data: %s",
| ^~
ibm_db.c:9434:25: note: ‘sprintf’ output between 21 and 1060 bytes into a destination of size 1039
9434 | sprintf(error, "Failed to LOB Data: %s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9435 | IBM_DB_G(__python_stmt_err_msg));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ibm_db.c:9420:71: warning: ‘%s’ directive writing up to 1039 bytes into a region of size 1013 [-Wformat-overflow=]
9420 | sprintf(error, "Failed to fetch LOB Data: %s",
| ^~
ibm_db.c:9420:29: note: ‘sprintf’ output between 27 and 1066 bytes into a destination of size 1039
9420 | sprintf(error, "Failed to fetch LOB Data: %s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9421 | IBM_DB_G(__python_stmt_err_msg));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -pthread -shared build/temp.linux-x86_64-cpython-311/ibm_db.o -L/root/db2driver/clidriver/lib -L/usr/local/lib -ldb2 -o build/lib.linux-x86_64-cpython-311/ibm_db.cpython-311-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -ldb2
collect2: error: ld returned 1 exit status
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for ibm_db
ERROR: Could not build wheels for ibm_db, which is required to install pyproject.toml-based projects
Failed to build ibm_db
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
我手动下载的库来自以下URL
https://github.com/ibmdb/db2drivers/raw/main/clidriver/linuxx64_odbc_cli.tar.gz
现在我不确信是错误的。
谢谢你给我指明了正确的方向。
斯蒂芬
1条答案
按热度按时间s1ag04yj1#
查看错误消息
/usr/bin/ld: cannot find -ldb2
,这意味着链接器无法定位您的Db2库。请查看readme页面上的说明,特别是在构建之前,导出环境变量LD_LIBRARY_PATH,其中包含一个条目,以包含包含您的Db2库的目录:
(for在linux
export LD_LIBRARY_PATH=$IBM_DB_HOME/lib:$LD_LIBRARY_PATH
上的示例)