[cx-oracle-users] Building cx_Oracle 5.2: undefined symbol: PyUnicodeUCS2_AsEncodedString
Brought to you by:
atuining
|
From: <ejo...@ea...> - 2015-10-23 19:54:16
|
I am have a pretty rough time of trying to get cx_Oracle build in some
state I can use.
BACKGROUND: I am directly on the Linux server that is hosting the Oracle DB
I want to talk to. So, I am not installing any client software, thinking I
can link directly with the server libraries.
The server has Python 2.6 installed on it, but when trying to run python
setup.py, I see all sort of complaints about libraries such as Python.h
and others that it can't find.
I'm not a guru C developer, gcc user or Linux wizard, but I know enough
to be dangerous.
WHAT I HAVE DONE
So, I don't know why those are not found .h files are not found.
Indeed, if I dig around on the system, I can't find them. So, I
figured screw it - I'll just go fetch Python sources myself, which I
have done for Python 2.6. I then run configure in the python directory,
which generates pyconfig.h, and I copy that down a level into Include/.
So, then I just hacked the gcc command that was output from python
setup.py to add this include directory (last argument before -c):
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/software/app/oracle/product/11.2.0Qv2/rdbms/demo -I/software/app/oracle/product/11.2.0Qv2/rdbms/public -I/usr/include/python2.6 -I/home/epjohn/src/Python-2.6.6/Include -c cx_Oracle.c -o build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.2
This silently generates cx_Oracle.o.
I then run this other gcc command, also seen in setup.py output (appears
to be to link the .o we just made with the rest of the stuff to make a
shared object). So, indeed, this will silently generate cx_Oracle.so:
gcc -pthread -shared build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -L/software/app/oracle/product/11.2.0Qv2/lib -lclntsh -o build/lib.linux-x86_64-2.6-11g/cx_Oracle.so
That seems to be the magic gem I am after.
I copy that .so into a convenient place at /home/epjohn/pythonlib/
But when I try to use it, I get this ugly error message:
epjohn$ python
Python 2.6.6 (r266:84292, Jul 23 2015, 05:13:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/home/epjohn/pythonlib')
>>> import cx_Oracle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/epjohn/pythonlib/cx_Oracle.so: undefined symbol: PyUnicodeUCS2_AsEncodedString
Just doing a Google search on PyUnicodeUCS2_AsEncodedString leads
straight to a StackOverflow article that is (somewhat surprisingly), from
someone trying to get cx_Oracle installed:
http://stackoverflow.com/questions/7951618/cx-oracle-so-undefined-symbolpyunicodeucs2-asencodedstring
I'm not sure I follow every detail there, but the general gist seems to
be to upgrade to cx_Oracle 5.1. But I'm already at 5.2.
So... as best as I can figure it out, there's some sort of
incompatibility between the way cx_Oracle module wants to handle Unicode
strings and the way the default Python installation wants to handle them?
I don't know... that's a guess, but can anybody provide a solution for
how I can get these two to sync up?
I do not have admin privileges on this machine, so modifying the
existing Python, installing a new Python, installing cx_Oracle via pip,
etc. are not options for me. Because of politics, I am basically on my
own to try to get this going.
(I had tried to first just build my own Python 2.7.10 from source,
thinking I would then just use pip to install cx_Oracle, but then I ran
into missing modules, like curses and readline because it couldn't find
various libraries, and again, I can't seem to locate readline libs on
this system. So, it is much preferable to just try to get a working
cx_Oracle.so that the existing Python 2.6.6 can communicate with. That's
my goal.)
Thank you for reading my email.
Your time and consideration on this issue is greatly appreciated.
Desperately-hoping-for-some-help-ly,
Erik Johnson
|