Thread: import error undefined symbol: PyUnicodeUCS2_Decode
I'm trying to port a Python app from Ubuntu to CentOS 5.5. When I try to import psycopg2, I get this:
ImportError: /usr/lib/python2.6/site-packages/psycopg2/_psycopg.so: undefined symbol: PyUnicodeUCS2_Decode
My code is built against python 2.6 and python 2.6 is installed on the CentOS machine, but it's not the default Python. (CentOS becomes very unhappy if I try to make 2.6 the default.)
I downloaded and extracted psycopg2 version 2.4.4 from http://initd.org/psycopg/download/and have performed the following steps:
python26 setup.py build
python26 setup.py install
Hoping to get lucky, I replaced the _psycopg2.so file on the CentOS box with the _psycopg2 from my (working) Ubuntu machine. That just got me another error:
ImportError: can't import mx.DateTime module
Python 2.6 seems to have been compiled with UCS4, and I am building
psycopg2 against 2.6, but when I do that it still seems to be looking for a UCS2 symbol.
Am I missing a step somewhere?
On Mon, Jan 16, 2012 at 4:39 PM, Jason Horning <jason.horning@bullberrysystems.com> wrote: > I'm trying to port a Python app from Ubuntu to CentOS 5.5. When I try to > import psycopg2, I get this: > > ImportError: /usr/lib/python2.6/site-packages/psycopg2/_psycopg.so: > undefined symbol: PyUnicodeUCS2_Decode > > My code is built against python 2.6 and python 2.6 is installed on the > CentOS machine, but it's not the default Python. (CentOS becomes very > unhappy if I try to make 2.6 the default.) > > I downloaded and extracted psycopg2 version 2.4.4 from > http://initd.org/psycopg/download/and have performed the following steps: > > python26 setup.py build > python26 setup.py install Are you sure it is installed where then it gets imported, i.e. in </usr/lib/python2.6/site-packages/>? > Hoping to get lucky, I replaced the _psycopg2.so file on the CentOS box with > the _psycopg2 from my (working) Ubuntu machine. That just got me another > error: > > ImportError: can't import mx.DateTime module This error shouldn't be reported since psycopg 2.4.2. You can install mx.DateTime to see if it solves the problem though. > Python 2.6 seems to have been compiled with UCS4, and I am building > psycopg2 against 2.6, but when I do that it still seems to be looking for a > UCS2 symbol. I think you are using two different python executables to build psycopg and to use it. > Am I missing a step somewhere? You may try some solution to keep a clean and consistent Python environment, such as virtualenv. About psycopg, if it is compiled and used with a consistent python version, it should work fine for both USC2 and UCS4 builds. -- Daniele
Daniele, For some reason python26 setup.py build was not rebuilding the files so we dropped the existing build directory for lib.linux-i686-2.6and ran python26 setup.py build again. This generated a new _psycopg.so file (along with other pythonsource files) and allowed the subsequent install and import to succeed. Jason -----Original Message----- From: psycopg-owner@postgresql.org [mailto:psycopg-owner@postgresql.org] On Behalf Of Daniele Varrazzo Sent: Monday, January 16, 2012 11:10 AM To: Jason Horning Cc: psycopg@postgresql.org Subject: Re: [psycopg] import error undefined symbol: PyUnicodeUCS2_Decode On Mon, Jan 16, 2012 at 4:39 PM, Jason Horning <jason.horning@bullberrysystems.com> wrote: > I'm trying to port a Python app from Ubuntu to CentOS 5.5. When I try > to import psycopg2, I get this: > > ImportError: /usr/lib/python2.6/site-packages/psycopg2/_psycopg.so: > undefined symbol: PyUnicodeUCS2_Decode > > My code is built against python 2.6 and python 2.6 is installed on the > CentOS machine, but it's not the default Python. (CentOS becomes very > unhappy if I try to make 2.6 the default.) > > I downloaded and extracted psycopg2 version 2.4.4 from > http://initd.org/psycopg/download/and have performed the following steps: > > python26 setup.py build > python26 setup.py install Are you sure it is installed where then it gets imported, i.e. in </usr/lib/python2.6/site-packages/>? > Hoping to get lucky, I replaced the _psycopg2.so file on the CentOS > box with the _psycopg2 from my (working) Ubuntu machine. That just > got me another > error: > > ImportError: can't import mx.DateTime module This error shouldn't be reported since psycopg 2.4.2. You can install mx.DateTime to see if it solves the problem though. > Python 2.6 seems to have been compiled with UCS4, and I am building > psycopg2 against 2.6, but when I do that it still seems to be looking > for a > UCS2 symbol. I think you are using two different python executables to build psycopg and to use it. > Am I missing a step somewhere? You may try some solution to keep a clean and consistent Python environment, such as virtualenv. About psycopg, if it iscompiled and used with a consistent python version, it should work fine for both USC2 and UCS4 builds. -- Daniele -- Sent via psycopg mailing list (psycopg@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/psycopg