ImportError: ibm_db_dlls/ibm_db.dll: invalid ELF header

791 views
Skip to first unread message

Greg Jewett

unread,
Feb 23, 2016, 12:36:35 AM2/23/16
to ibm_db
All..

I have tried all day to figure out how to get this python module to work.

OS:  Linux bacsdev.its.utexas.edu 2.6.32-573.1.1.el6.x86_64 #1 SMP Tue Jul 14 02:46:51 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
Python: Python 2.7.9

Was able to get everything to build and install, but ran into the following errors, which can probably be figured out, just not sure how to attack it yet.

Python 2.7.9 (default, Dec 16 2014, 10:42:10) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ibm_db.py", line 7, in <module>
    __bootstrap__()
  File "ibm_db.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
ImportError: ibm_db_dlls\ibm_db.dll: cannot open shared object file: No such file or directory


The "slash" found in the path above is the wrong one. When I flip it from a back-slash to the front-slash (normal), the error moves to the ELF error below.


Python 2.7.9 (default, Dec 16 2014, 10:42:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ibm_db.py", line 7, in <module>
    __bootstrap__()
  File "ibm_db.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
ImportError: ibm_db_dlls/ibm_db.dll: invalid ELF header


This error is most likely due to the binaries not built for the OS I am currently using. There are both 32-bit and 64-bit versions, but neither work.

Oct 28 11:12 ibm_db32_py25.pyd
Oct 28 10:51 ibm_db32_py26.pyd
Oct 28 10:32 ibm_db32_py27.pyd
Oct 28 10:12 ibm_db32_py32.pyd
Oct 28 09:49 ibm_db32_py33.pyd
Oct 28 09:37 ibm_db32_py34.pyd
Oct 28 02:27 ibm_db64_py27.pyd
Oct 28 01:26 ibm_db64_py33.pyd
Oct 28 01:04 ibm_db64_py34.pyd


Any thoughts?


I am using the following "clidrivers"


hemlatabhattibm

unread,
Feb 23, 2016, 1:39:56 AM2/23/16
to ibm_db
Hi Greg,

In the ibm_db folder a file is generated which contains a .pyc extension can you try by renaming the file (to like .pyc.old) and try.

Regards,
Hema

Greg Jewett

unread,
Feb 23, 2016, 11:33:19 PM2/23/16
to ibm_db
Thanks for replying Hema!

Nope, that did not work.  Any other thoughts?

# rm -Rf /usr/local/lib/python2.7/site-packages/ibm_db-2.0.6-py2.7-linux-x86_64.egg/
# rm -Rf build/
# rm -Rf dist
# rm -f *.pyc
# cp ibm_db64_py27.pyd ./ibm_db_dlls/ibm_db.dll
cp: overwrite `./ibm_db_dlls/ibm_db.dll'? y
# python setup.py build
... build info ...
# python setup.py install
... install info ....

[root@bacsdev ibm_db-2.0.6]# python

Python 2.7.9 (default, Dec 16 2014, 10:42:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ibm_db.py", line 7, in <module>
    __bootstrap__()
  File "ibm_db.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
ImportError: ibm_db_dlls/ibm_db.dll: invalid ELF header

Saba Kauser

unread,
Feb 23, 2016, 11:34:27 PM2/23/16
to ibm_db
Greg, you need to rename the file after the image is installed. i.e after python setup.py install.

Greg Jewett

unread,
Feb 24, 2016, 10:30:36 PM2/24/16
to ibm_db
OK, deleted the file before running Python and trying to "import ibm_db".  Same error.  Swapped out the *.pyd file and still same error.

# rm ibm_db.pyc
rm: remove regular file `ibm_db.pyc'? y
# python
Python 2.7.9 (default, Dec 16 2014, 10:42:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ibm_db.py", line 7, in <module>
    __bootstrap__()
  File "ibm_db.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
ImportError: ibm_db_dlls/ibm_db.dll: invalid ELF header

hemlatabhattibm

unread,
Feb 25, 2016, 12:37:14 AM2/25/16
to ibm_db
Hi Greg ,

Can you try installing ibm_db by using easy_install ibm_db which is the recommended way.Please follow the link for setup and installation.

  https://github.com/ibmdb/python-ibmdb/tree/master/IBM_DB/ibm_db

Regards
Hema

Greg Jewett

unread,
Feb 26, 2016, 5:22:56 AM2/26/16
to ibm_db
I am on a closed system, on a private network with no internet access.
If I can download all the pieces and then instruct easy_install to use those pieces, versus having to download them -- I can do that.    Do you know of a way to do that?

hemlatabhattibm

unread,
Feb 26, 2016, 5:28:48 AM2/26/16
to ibm_db
Hi Greg,

After build and install remove any .pyc (if any) and move the ibm_db.py to ibm_db.py.old and then try a import ibm_db.

$rm -rf  *.pyc
$mv ibm_db.py ibm_db.py.old

$python
Python 2.7.9 (default, Feb 26 2016, 20:31:21)
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
>>>

Regards
Hema

Greg Jewett

unread,
Feb 29, 2016, 1:05:31 AM2/29/16
to ibm_db
Thank you again!  I appreciate you willingness to help me!  Stuck again, new error.

I purged all build and install contents:
rm -Rf build/
rm -Rf dist
rm -Rf /usr/local/lib/python2.7/site-packages/ibm_db-2.0.6-py2.7-linux-x86_64.egg/
cp -f ibm_db64_py27.pyd ./ibm_db_dlls/ibm_db.dll

Transcript:

# python setup.py build
... build info ...
# python setup.py install
... install info ...
# rm -f *.pyc
# mv ibm_db.py ibm_db.py.old

# python
Python 2.7.9 (default, Dec 16 2014, 10:42:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libdb2.so.1: cannot open shared object file: No such file or directory

I looked for the "
libdb2.so.1" file and found it:
/opt/pyInformix/ibm_db-2.0.6/clidriver/lib/libdb2.so
/opt/pyInformix/ibm_db-2.0.6/clidriver/lib/libdb2.so.1





hemlatabhattibm

unread,
Feb 29, 2016, 2:00:45 AM2/29/16
to ibm_db
Hi Greg ,

The file is present but cannot be accessed .Can you check the permissions in folder /opt/pyInformix/ibm_db-2.0.6/clidriver/lib/ and make sure IBM_DB_HOME is set .

Regards
Hema

Greg Jewett

unread,
Mar 1, 2016, 2:50:50 AM3/1/16
to ibm_db
Or another thought..
Can I install the ibm_db on another identical system that does have internet access and then copy over all the related files to the closed system.  Would that work?  Do you know the paths and pieces that I would copy?


On Wednesday, February 24, 2016 at 11:37:14 PM UTC-6, hemlatabhattibm wrote:

Kevin Adler

unread,
Mar 1, 2016, 2:50:50 AM3/1/16
to ibm...@googlegroups.com
It looks like you're running Linux and it's trying to load the Windows DLL
(which does not have an ELF header, since it's in PE32 format). This would
indicate to me that somehow you got the Windows egg installed somehow.

ibm...@googlegroups.com wrote on 02/24/2016 10:16:40 AM:
> --
> You received this message because you are subscribed to the Google
> Groups "ibm_db" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to ibm_db+un...@googlegroups.com.
> To post to this group, send email to ibm...@googlegroups.com.
> Visit this group at https://groups.google.com/group/ibm_db.
> For more options, visit https://groups.google.com/d/optout.

Greg Jewett

unread,
Mar 2, 2016, 4:41:02 AM3/2/16
to ibm_db
THANK YOU hemlatabhattibm, kad...@us.ibm.com, and Saba Kauser!   Milestone reached!

I appreciate all the help.  I am not sure how or why, but "kad...@us.ibm.com" hit it on the head, when it may have been windows download?  That sounds plausible.
However, it was the suggestion of "hemlatabhattibm" that I believe was the answer, try to install it (using pip install ibm_db) on another machine, then move it over.  I had no idea what files to copy, so I took a guess.   I installed it, it compiled and created the files.  I then took a guess at the files (got lucky):
  • /usr/local/lib/python*/site-packages/clidriver/*
  • /usr/local/lib/python*/site-packages/ibm*

I then made sure IBM_DB_HOME was set to:  /usr/local/lib/python*/site-packages/clidriver/

I was able to "import ibm_db", and no errors.

However, I am now stuck at:
Segmentation fault (core dumped)
Python is killed off.

Ugh!  I have tried the clidriver from the build on the other machine and I have tried the clidriver I downloaded.  Thinking that this is where the binaries are, this must be the code that is causing the segmentation fault.
I did not see any difference in the driver for 32 or 64 bit.

Thoughts?

Saba Kauser

unread,
Mar 8, 2016, 3:36:29 AM3/8/16
to ibm_db
The python ibm_db package contains ibm_db.py file for using windows binaries. When you perform a build and install, ibm_db.py would be generated under site-packages/<ibm_db egg folder> with correct library name and gets picked up for import. However, when you are under the source code directory, ibm_db.py for windows gets picked up from current working directory and fails with error.

Workaround to rename ibm_db.py from source code should work.
This can be fixed in next ibm_db release. Changes will be pushed to github shortly.

for the segmentation fault, please share db2dump folder under clidriver and also share db2 traces for the  problem.

Quikjean

unread,
Mar 8, 2016, 8:21:40 AM3/8/16
to ibm_db
Hi

I have just downloaded and installed Python DB2 drivers on an Ubuntu server.

I got the source at :
https://pypi.python.org/pypi/ibm_db

I issued :
> sudo python setup.py build
> sudo python setup.py install

The commands ran successfully but as Greg, I have the same result that looks like a Windows DLL
and import command fails.

Greg did you resolve your issue ?

Thanks

Quikjean

unread,
Mar 8, 2016, 8:21:41 AM3/8/16
to ibm_db
I found something interesting

import ibm_db works actually fine... you must be outside from the folder where you extract the install files

example :
I am in /home/jean -> I run import_db, it works fine
I am in /home/jean/ibm_db-2.0.6 -> I run import_db and it fails

It could be the same error as you got
Reply all
Reply to author
Forward
0 new messages