首页 > 解决方案 > Python 的 IBM_DB 包似乎没有 IBM_DB.dll

问题描述

免责声明:我是 Python 的新手。

在过去的几天里,我一直在尝试使用 Python 访问 DB2 数据库,但到目前为止我的尝试都没有成功。

我已经通过执行以下命令安装了“ibm_db”包:pip install ibm_db,它似乎安装成功。因此,当我尝试导入 ibm_db 时,我不再收到“找不到 ibm_db 的模块”错误。另外,我已经相应地设置了 IBM_DB_HOME。

但是,当我尝试执行以下代码时,我现在收到此错误: ImportError: DLL load failed while importing ibm_db: The specified module could not be found。

我已经爬到互联网上查看我缺少的内容,发现我没有任何 IBM_DB_DLL 文件夹或 IBM_DB.dll。

我如何获得这些文件?

系统和安装细节:

Windows 10 - 64 位

Python 版本 - win32 上的 Python 3.8.0 [MSC v.1916 64 位 (AMD64)] -- 我不知道win32是什么意思。我已经从 Python 网站安装了这个版本(Windows x86-64 可执行安装程序)。

我还安装了'IBM DB2 Runtime Client 10.5fp8

IBM_DB_HOME 变量设置为:C:\Python\Lib\site-packages

我能够在 Python 中运行其他程序。但是,这是我第一次尝试连接到 DB2。

任何帮助或点都非常感谢。

提前致谢,

加内什



def make_connexion(server, port, database, username, password, timeout):
return db2.connect('DATABASE={0};'.format(database) +
                  'HOSTNAME={0};'.format(server) +
                  'PORT={0};'.format(str(port)) +
                  'PROTOCOL=TCPIP;' +
                  'UID={0};'.format(username) +
                  'PWD={0};'.format(password) +
                  'ConnectTimeout={0};'.format(str(timeout))
                  , '', '')

--sample connexion object

connexion = make_connexion('server', 'port', 'database', 'username', 'password', 'timeout')

使用 easy_install ibm_db 卸载并重新安装 ibm_db 包后,我注意到警告消息显示警告:在目录 'ibm_db_dlls' 下找不到匹配''的文件*

这是我尝试安装 ibm_db 包时的完整日志

C:\Users\me\AppData\Local\Programs\Python\Python38\Scripts>easy_install ibm_db
Searching for ibm_db
Reading https://pypi.org/simple/ibm_db/
Downloading https://files.pythonhosted.org/packages/98/cb/f77d9bd5f64246074af364cc30e20e3044c533890f3b67d30e89615c2fc5/ibm_db-3.0.1.tar.gz#sha256=a609e07295d16455d40df94ddd61b3d476606f5d44e3352103776e3ecbff185a
Best match: ibm-db 3.0.1
Processing ibm_db-3.0.1.tar.gz
Writing C:\Users\me\AppData\Local\Temp\easy_install-vdcgwf_i\ibm_db-3.0.1\setup.cfg
Running ibm_db-3.0.1\setup.py -q bdist_egg --dist-dir C:\Users\me\AppData\Local\Temp\easy_install-vdcgwf_i\ibm_db-3.0.1\egg-dist-tmp-3p_6emad
Detected 64-bit Python
Downloading https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ntx64_odbc_cli.zip
warning: no files found matching '*' under directory 'ibm_db_dlls'
warning: no previously-included files found matching 'config.py'
ibm_db.c
ibm_db.c(268): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
ibm_db.c(279): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
ibm_db.c(467): warning C4047: '!=': 'SQLHANDLE' differs in levels of indirection from 'int'
ibm_db.c(667): warning C4312: 'type cast': conversion from 'long' to 'SQLPOINTER' of greater size
ibm_db.c(699): warning C4312: 'type cast': conversion from 'long' to 'SQLPOINTER' of greater size
ibm_db.c(724): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(1257): warning C4312: 'type cast': conversion from 'long' to 'SQLPOINTER' of greater size
ibm_db.c(1305): warning C4244: 'function': conversion from 'Py_ssize_t' to 'SQLSMALLINT', possible loss of data
ibm_db.c(1307): warning C4244: 'function': conversion from 'Py_ssize_t' to 'SQLSMALLINT', possible loss of data
ibm_db.c(1309): warning C4244: 'function': conversion from 'Py_ssize_t' to 'SQLSMALLINT', possible loss of data
ibm_db.c(1305): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c:\users\me\appdata\local\programs\python\python38\include\unicodeobject.h(177): note: see declaration of 'PyUnicode_GetSize'
ibm_db.c(1307): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c:\users\me\appdata\local\programs\python\python38\include\unicodeobject.h(177): note: see declaration of 'PyUnicode_GetSize'
ibm_db.c(1309): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c:\users\me\appdata\local\programs\python\python38\include\unicodeobject.h(177): note: see declaration of 'PyUnicode_GetSize'
ibm_db.c(1452): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(1920): warning C4244: '=': conversion from 'INT_PTR' to 'int', possible loss of data
ibm_db.c(2019): warning C4244: '=': conversion from 'INT_PTR' to 'int', possible loss of data
ibm_db.c(2305): warning C4312: 'type cast': conversion from 'unsigned long' to 'SQLPOINTER' of greater size
ibm_db.c(2679): warning C4244: 'function': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(5155): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(5155): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c:\users\me\appdata\local\programs\python\python38\include\unicodeobject.h(177): note: see declaration of 'PyUnicode_GetSize'
ibm_db.c(5352): warning C4267: '=': conversion from 'size_t' to 'SQLINTEGER', possible loss of data
ibm_db.c(5387): warning C4267: '=': conversion from 'size_t' to 'SQLINTEGER', possible loss of data
ibm_db.c(5478): warning C4244: '=': conversion from 'Py_ssize_t' to 'SQLINTEGER', possible loss of data
ibm_db.c(5489): warning C4244: '=': conversion from 'Py_ssize_t' to 'SQLINTEGER', possible loss of data
ibm_db.c(5504): warning C4018: '<=': signed/unsigned mismatch
ibm_db.c(5520): warning C4018: '<=': signed/unsigned mismatch
ibm_db.c(5616): warning C4244: '=': conversion from 'Py_ssize_t' to 'SQLINTEGER', possible loss of data
ibm_db.c(5627): warning C4267: '=': conversion from 'size_t' to 'SQLINTEGER', possible loss of data
ibm_db.c(5641): warning C4018: '<=': signed/unsigned mismatch
ibm_db.c(5766): warning C4267: '=': conversion from 'size_t' to 'SQLINTEGER', possible loss of data
ibm_db.c(5489): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c:\users\me\appdata\local\programs\python\python38\include\unicodeobject.h(177): note: see declaration of 'PyUnicode_GetSize'
ibm_db.c(5995): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(5966): warning C4101: 'curr_ptr': unreferenced local variable
ibm_db.c(5966): warning C4101: 'prev_ptr': unreferenced local variable
ibm_db.c(7734): warning C4047: '!=': 'SQLHANDLE' differs in levels of indirection from 'int'
ibm_db.c(7747): warning C4047: '=': 'SQLHANDLE' differs in levels of indirection from 'int'
ibm_db.c(8313): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
ibm_db.c(8318): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
ibm_db.c(10318): warning C4244: 'function': conversion from 'SQLINTEGER' to 'SQLSMALLINT', possible loss of data
ibm_db.c(10437): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(10454): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(10738): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
ibm_db.c(10805): warning C4047: '==': 'SQLINTEGER' differs in levels of indirection from 'void *'
   Creating library build\temp.win-amd64-3.8\Release\ibm_db.cp38-win_amd64.lib and object build\temp.win-amd64-3.8\Release\ibm_db.cp38-win_amd64.exp
Generating code
c:\users\me\appdata\local\temp\easy_install-vdcgwf_i\ibm_db-3.0.1\ibm_db.c(7195) : warning C4715: 'ibm_db_field_nullable': not all control paths return a value
Finished generating code
zip_safe flag not set; analyzing archive contents...
__pycache__.ibm_db.cpython-38: module references __file__
__pycache__.testfunctions.cpython-38: module MAY be using inspect.stack
tests.__pycache__.test_000_PrepareDb.cpython-38: module references __file__
tests.__pycache__.test_144_BindParamInsertStmtPARAM_FILE.cpython-38: module references __file__

****************************************
You are downloading a package which includes the Python module for IBM DB2/Informix.  The module is licensed under the Apache License 2.0. The package also includes IBM ODBC and CLI Driver from IBM, which is automatically downloaded as the python module is installed on your system/device. The license agreement to the IBM ODBC and CLI Driver is available in c:\users\me\appdata\local\programs\python\python38\Lib\site-packages\clidriver or c:\users\me\appdata\local\programs\python\python38\Lib\site-packages\ibm_db-3.0.1-py3.8.egg\clidriver.   Check for additional dependencies, which may come with their own license agreement(s). Your use of the components of the package and dependencies constitutes your acceptance of their respective license agreements. If you do not accept the terms of any license agreement(s), then delete the relevant component(s) from your device.
****************************************
creating c:\users\me\appdata\local\programs\python\python38\lib\site-packages\ibm_db-3.0.1-py3.8-win-amd64.egg
Extracting ibm_db-3.0.1-py3.8-win-amd64.egg to c:\users\me\appdata\local\programs\python\python38\lib\site-packages
Adding ibm-db 3.0.1 to easy-install.pth file

Installed c:\users\me\appdata\local\programs\python\python38\lib\site-packages\ibm_db-3.0.1-py3.8-win-amd64.egg
Processing dependencies for ibm_db
Finished processing dependencies for ibm_db

C:\Users\me\AppData\Local\Programs\Python\Python38\Scripts>

标签: python-3.xdb2

解决方案


我个人无法在我的 Python 3.8 安装中安装 IBM DB v3.0.1。有很多错误等等。但是,我在安装 3.7.4 时没有遇到任何问题。


推荐阅读