Thread: Python UCS4 error

Python UCS4 error

From
c k
Date:
Dear All,
I updated my development machine with Fedora 15 and as there is python 2.7. I have also migrated my few postgresql databases. While creating plpython in one database, I got the following error undefined symbol PyUnicodeUCS4_AsEncodedString.
Then I recompiled source code and got a plpython.so compiled for python 2.7 (default python comes with fedora15) and replaced original with this one. Restarted postgresql and still same error occurs.
When checked for where a python is with ucs4  or ucs2 using following script, it says it is ucs4.
>>> import sys
>>> print sys.maxunicode
1114111

How to solve this error?
Waiting for your help !

Regards,

C P Kulkarni

Re: [ADMIN] Python UCS4 error

From
Tom Lane
Date:
c k <shreeseva.learning@gmail.com> writes:
> I updated my development machine with Fedora 15 and as there is python 2.7.
> I have also migrated my few postgresql databases. While creating plpython in
> one database, I got the following error undefined symbol
> PyUnicodeUCS4_AsEncodedString.
> Then I recompiled source code and got a plpython.so compiled for python 2.7
> (default python comes with fedora15) and replaced original with this one.
> Restarted postgresql and still same error occurs.

plpython seems to work for me on Fedora 15, so you're going to need to
be more specific about how to trigger this error.

            regards, tom lane

Re: [ADMIN] Python UCS4 error

From
c k
Date:
I have default python 2.7.1 installed along with fedora15. Then installed postgresql from binary installers. This creates the plpython.so, plpython2.so and plpython3.so in lib/postgresql directory under postgresql installation. When I go for creating a new language plpython, it gives me some error regarding pythonś version. By default it is compiled with 2.6 and I have 2.7, so I need to get source code and compile it against python 2.7. For this I will configure --with-python option and see which python it uses and where it is located. For me it used python 2.7 and shown the python default installation. Then I used ´make' and ´make install world´ and copied plpython.so and plpython2.so to new postgresql installation. Started the server and try to create new language, then the earlier mentioned error comes as
undefined symbol: PyUnicodeUCS4_AsEncodedString.
Previously It was working on fedora 14 . It seems that I have to recompile and install python 2.7 at another location and use it for postgresql make process. But not sure that it will solve error.
Thanks and regards,

C P Kulkarni

On Wed, Jul 6, 2011 at 12:24 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
c k <shreeseva.learning@gmail.com> writes:
> I updated my development machine with Fedora 15 and as there is python 2.7.
> I have also migrated my few postgresql databases. While creating plpython in
> one database, I got the following error undefined symbol
> PyUnicodeUCS4_AsEncodedString.
> Then I recompiled source code and got a plpython.so compiled for python 2.7
> (default python comes with fedora15) and replaced original with this one.
> Restarted postgresql and still same error occurs.

plpython seems to work for me on Fedora 15, so you're going to need to
be more specific about how to trigger this error.

                       regards, tom lane

Re: [ADMIN] Python UCS4 error

From
John R Pierce
Date:
On 07/05/11 7:34 PM, c k wrote:
> I have default python 2.7.1 installed along with fedora15. Then
> installed postgresql from binary installers. This creates the
> plpython.so, plpython2.so and plpython3.so in lib/postgresql directory
> under postgresql installation. When I go for creating a new language
> plpython, it gives me some error regarding pythonś version. By default
> it is compiled with 2.6 and I have 2.7...

the first statement and last seem in contradiction.    when you say
'default python 2.7.1 installed', do you mean the default python thats
shipped with Fedora 15 is 2.7 ?

if Fedora 15 ships with Python 2.7, then it appears the 'postgresql from
binary installers' you installed was not built for Fedora 15.   Which
'binary installers' were these?   The default postgresql 9.0 that is
bundled with Fedora, or something else?



--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast



Re: [ADMIN] Python UCS4 error

From
c k
Date:
yes, shipped with fedora 15 and binary installers are from EnterpriseDB - all in one.
CPK

On Wed, Jul 6, 2011 at 8:36 AM, John R Pierce <pierce@hogranch.com> wrote:
On 07/05/11 7:34 PM, c k wrote:
I have default python 2.7.1 installed along with fedora15. Then installed postgresql from binary installers. This creates the plpython.so, plpython2.so and plpython3.so in lib/postgresql directory under postgresql installation. When I go for creating a new language plpython, it gives me some error regarding pythonś version. By default it is compiled with 2.6 and I have 2.7...

the first statement and last seem in contradiction.    when you say 'default python 2.7.1 installed', do you mean the default python thats shipped with Fedora 15 is 2.7 ?

if Fedora 15 ships with Python 2.7, then it appears the 'postgresql from binary installers' you installed was not built for Fedora 15.   Which 'binary installers' were these?   The default postgresql 9.0 that is bundled with Fedora, or something else?



--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [ADMIN] Python UCS4 error

From
c k
Date:
Solved.
Here is the procedure to get working with plpython ucs2 or ucs4 error. By default python uses ucs2 and we have to change it to ucs4.
compile python2.7 or 3 with options as below.
./configure --enable-unicode=ucs4
then use
make and make altinstall
then use the python path for postgresql source configuration within postgresql source directory
./configure --with-python PYTHON=/usr/local/bin/python2.7 (replace with your python installation path)
then use
make and make install-world
Copy the plpython.so, plpython2.so or plpython3.so from local postgresql install directory (normally /usr/local/pgsql/lib) to the required installtion lib directory.
make proper local links to files if required.
start the postgresql
with a database create a new language as plpythonu, plpython2u or plpython3u as required.
create a simple function as below to test plpython working
CREATE or replace FUNCTION pyver() RETURNS text
    LANGUAGE plpythonu
    AS $$
import sys
#return sys.version
return sys.path
$$;

if it shown the version then check it with your newly installed alternative python version. Also check path from function and from python. If both matches then you can use plpython properly.

Regards,
C P Kulkarni
On Wed, Jul 6, 2011 at 9:25 AM, John R Pierce <pierce@hogranch.com> wrote:
On 07/05/11 8:33 PM, c k wrote:
yes, shipped with fedora 15 and binary installers are from EnterpriseDB - all in one.


any reason you didn't use the Fedora 15 native version of Postgres 9.0.x ?    should be as simple as

   $ sudo yum install postgresql-server






--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast