undefined symbol: PyUnicodeUCS4_FromEncodedObject

I just switched my Linux installation to Kubuntu and now I am trying to get
my wxPython programs to run on Linux. I get the message:

undefined symbol: PyUnicodeUCS4_FromEncodedObject

I can see that there is apparently a Unicode issue, but I don't know what to
do. I'm not even sure that this is a wxPython issue, but I get the message
when I import wx. I am running Kubuntu 6.10, Python 2.4.2, and the
wxPython from

deb http://wxpython.wxcommunity.com/apt/ubuntu/dapper

···

--
Jeffrey Barish

I had the same problem on SuSE 10.0. My workaround was to compile Python
with wide unicode support - i.e., passing --enable-unicode=ucs4 to the
Python configure script.

Regards,

Oliver

Jeffrey Barish wrote:

···

I just switched my Linux installation to Kubuntu and now I am trying to get
my wxPython programs to run on Linux. I get the message:

undefined symbol: PyUnicodeUCS4_FromEncodedObject

I can see that there is apparently a Unicode issue, but I don't know what to
do. I'm not even sure that this is a wxPython issue, but I get the message
when I import wx. I am running Kubuntu 6.10, Python 2.4.2, and the
wxPython from

deb NameBright - Coming Soon
  
--
--------------------------------------------------------------------
F. Oliver Gathmann, Ph.D.
Director IT Unit
Cenix BioScience GmbH
Tatzberg 47 phone: +49 (351) 4173-136
D-01307 Dresden, Germany fax: +49 (351) 4173-109

fingerprint: 8E0E 9A64 A07E 0D1A D302 34C2 421A AE9F 4E13 A009
public key: Typo | Odoo
--------------------------------------------------------------------

F. Oliver Gathmann wrote:

I had the same problem on SuSE 10.0. My workaround was to compile Python
with wide unicode support - i.e., passing --enable-unicode=ucs4 to the
Python configure script.

I tried what you suggested. Much to my amazement, I was able to compile a
new Python with little difficulty. However, before running make install, I
figured that I should remove the Python that was already on the system. On
Ubuntu, removing Python (using apt) removes most of the OS. I spent all
day yesterday reinstalling the OS. This time I figured I better ask first.
Where does make install put the new Python? If it puts the new Python
in /usr/local/bin (and does not pollute either /usr/bin or /usr/lib) then I
suppose that I could operate my system with two Pythons, but that solution
seems clumsy. Does anyone know whether there is a way to upgrade the
Python on Ubuntu to wide unicode support? Is there a wxPython package that
does not require wide unicode support? I see that there are both ansi- and
unicode-based packages for three RPM-based distributions. How about
Debian? I don't understand why there is a package in the Ubuntu repository
that does not run on the Python that ships with Ubuntu. Other than this
problem, I like Ubuntu (Kubuntu, actually) so far.

···

--
Jeffrey Barish

Jeffrey Barish wrote:

F. Oliver Gathmann wrote:

I had the same problem on SuSE 10.0. My workaround was to compile Python
with wide unicode support - i.e., passing --enable-unicode=ucs4 to the
Python configure script.

The Python on Ubuntu should already have the ucs4 unicode option turned on.

  $ python2.4
  Python 2.4.3 (#2, Oct 6 2006, 07:52:30)
  [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import sys
  >>> sys.maxunicode
  1114111
  >>>

The 111411 indicates it is using UCS4, if the value was 65535 then it would be UCS2. That's on Dapper, so unless they've changed it to UCS2 in Edgy for some reason there shouldn't be a need to rebuild anything.

I tried what you suggested. Much to my amazement, I was able to compile a
new Python with little difficulty. However, before running make install, I
figured that I should remove the Python that was already on the system. On
Ubuntu, removing Python (using apt) removes most of the OS. I spent all
day yesterday reinstalling the OS. This time I figured I better ask first. Where does make install put the new Python?

Wherever you specified with the --prefix= configure option. If you didn't specify anything then it will go to /usr/local.

If it puts the new Python
in /usr/local/bin (and does not pollute either /usr/bin or /usr/lib) then I
suppose that I could operate my system with two Pythons, but that solution
seems clumsy. Does anyone know whether there is a way to upgrade the
Python on Ubuntu to wide unicode support? Is there a wxPython package that
does not require wide unicode support? I see that there are both ansi- and
unicode-based packages for three RPM-based distributions. How about
Debian?

The UCS4/UCS2 issue is not the same. That option controls what size a character in a Python unicode object is, and also what related Python APIs are available. The wxPython ANSI/Unicode build options control whether wxString is essentially an array of char or an array of wchar_t values (where wchar_t may be two or four bytes depending on platform and compiler.)

The error you're getting is because wxPython was built with a Python (the one from the Ubuntu APT repository) that was built with the UCS4 option and so it is expecting to find the UCS4 API available when it is loaded, but your Python was built with the UCS2 option. Are you sure that your current Python is the one from the APT repository and hasn't been overwritten sometime in the past with another custom build? If so there is probably a way to force a reinstall of the repository Python without needing to uninstall it first.

If the Python in the repository has changed its build options (I guess I should just upgrade one of my machines and check...) then the correct thing to do is to rebuild wxPython. You can get the source package and use the package tools to do that build. I don't have the commands to do that handy at the moment, but it shouldn't be too hard for you to track it down.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

The 111411 indicates it is using UCS4, if the value was 65535 then it
would be UCS2. That's on Dapper, so unless they've changed it to UCS2
in Edgy for some reason there shouldn't be a need to rebuild anything.

Here's what I get:

$ python
Python 2.4.2 (#7, Sep 28 2005, 16:48:03)
[GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import sys
sys.maxunicode

65535

It is strange also that the version regressed to 2.4.2 from 2.4.3.

The UCS4/UCS2 issue is not the same. That option controls what size a
character in a Python unicode object is, and also what related Python
APIs are available. The wxPython ANSI/Unicode build options control
whether wxString is essentially an array of char or an array of wchar_t
values (where wchar_t may be two or four bytes depending on platform and
compiler.)

Yes, I understood that. But I was thinking that if there were a wxPython
build for ansi, then it wouldn't be using either UCS4 or UCS2 and so would
work with any Python.

Are you sure
that your current Python is the one from the APT repository and hasn't
been overwritten sometime in the past with another custom build?

I just installed the OS yesterday and I haven't done any custom builds on
the system, so the Python I am running is most likely the one that came off
the installation disc. I actually installed RC1, but if they replaced
Python between the time I downloaded the iso on W and the official release
yesterday, then it seems to me I would be seeing it offered as an upgrade.

If the Python in the repository has changed its build options (I guess I
should just upgrade one of my machines and check...) then the correct
thing to do is to rebuild wxPython.

I'll try that after I finish reinstalling the OS.

···

--
Jeffrey Barish

Jeffrey Barish wrote:

It is strange also that the version regressed to 2.4.2 from 2.4.3.

Mystery solved: there was a Python in my /usr/local/bin left over from the
previous OS which was getting picked up before the correct one in /usr/bin.
So, even though I had not done a custom build on the new OS, when I copied
the /usr/local/bin from the old OS, I inadvertently introduced a decoy.

Even though a few things are not working the way they did on XP, it's
beautiful seeing wxPython running on Linux.

···

--
Jeffrey Barish

Jeffrey Barish wrote:

Jeffrey Barish wrote:

It is strange also that the version regressed to 2.4.2 from 2.4.3.

Mystery solved: there was a Python in my /usr/local/bin left over from the
previous OS which was getting picked up before the correct one in /usr/bin. So, even though I had not done a custom build on the new OS, when I copied
the /usr/local/bin from the old OS, I inadvertently introduced a decoy.

Even though a few things are not working the way they did on XP, it's
beautiful seeing wxPython running on Linux.

Just for the record, Ubuntu Edgy includes Python 2.4.4c1 and it works fine with the wxPython packages currently in the wxCommunity repository that were built on Dapper.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!