import error undefined symbol: PyUnicodeUCS4_DecodeUTF8

1,933 views
Skip to first unread message

Andrew M. C. Dawes

unread,
May 11, 2012, 2:15:28 PM5/11/12
to qutip
I'm very excited to start working with QuTiP!

After installing into EPD 7.2 on Ubuntu 11.10 (and changing to a
different directory) I get the following error on running

from qutip import *

ImportError: /opt/epd-7.2-2-rh5-x86_64/lib/python2.7/site-packages/
qutip/cyQ/cy_mc_funcs.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8

Anyone dealt with this before? The install went smoothly on my mac
(also 64-bit EPD) so for now I'll work on that platform.

Thanks,
Andy

Paul Nation

unread,
May 11, 2012, 10:27:08 PM5/11/12
to qu...@googlegroups.com
Andy,

Glad to hear that you are interested in QuTiP!

We have not run into your error before.  However, a quick google search indicates that your issue is due to the cy_mc_funcs.so function being compiled with unicode support that differs from the unicode in your python distribution:

"This is usually caused by a mismatch in the Unicode mode of the python interpreter and the extension module. Python can be built to use either 2-byte or 4-byte Unicode code points.   If you build an extension on a Python interpreter that uses one, but use it on another, this error is the most common result."

Needless to say, something fishy is going on.  We do not use the EPD very much, and must request the links to the downloads from Enthought before we can see if this is reproducible.  We did check with EPD 7.1 in the past, and everything went ok.

One quick thing that may solve the problem is to first check that when you call python from the terminal, that it says the Python interpreter is from the EPD.  It should say something like "Python 2.7.3 [EPD 7.2.2 ….".  If not, then your python is not setup properly to use EPD from the command line.(On the mac, installing EPD sets the EPD Python to default, but if I remember correctly it does not do this on linux for compatibility reasons.)  

If it checks out, go into the downloaded qutip-1.1.3 folder and cd to:

qutip/cyQ/

and from the terminal run:

python setup.py build_ext --inplace

and then try to install again.  Essentially, you are rebuilding the c-code files from their Cython source.  If the error still occurs, then I think Distutils is linking to the wrong Python header files.

Let us know how it goes.

Best regards,

Paul

Andrew M. C. Dawes

unread,
May 12, 2012, 1:20:15 AM5/12/12
to qutip

> One quick thing that may solve the problem is to first check that when you call python from the terminal, that it says the Python interpreter is from the EPD.  It should say something like "Python 2.7.3 [EPD 7.2.2 ….".  If not, then your python is not setup properly to use EPD from the command line.(On the mac, installing EPD sets the EPD Python to default, but if I remember correctly it does not do this on linux for compatibility reasons.)

Yes, running Python correctly reports the EPD version on my mac and in
Ubuntu (both are running EPD 7.2-2).

>
> If it checks out, go into the downloaded qutip-1.1.3 folder and cd to:
>
> qutip/cyQ/
>
> and from the terminal run:
>
> python setup.py build_ext --inplace
>
> and then try to install again.  Essentially, you are rebuilding the c-code files from their Cython source.  If the error still occurs, then I think Distutils is linking to the wrong Python header files.

This did not seem to change anything. I suspect that the issue comes
from the sudo'ed python not being the EPD version. At first, I ran
"sudo python setup.py install" and then couldn't import qutip. To fix
that problem, I used the full path to EPD python in the sudo command.
While this correctly installs to the EPD python path, it may not be
compiling to the right python headers etc.

My solution today was to simply install the necessary packages to the
system python in ubuntu (also 64-bit python 2.7). With apt-get this is
easy (I only needed to add scipy and pyside, the rest I already had).

I'm happy to keep trying things to make EPD work for the sake of
helping others and resolving this issue, but my experience suggests
that in ubuntu, it is simple enough to install the required packages
and then install qutip.

-Andy

PS - To fix an error calling the "factorial" function, I had to
explicitly import that from scipy.misc in orbital.py, states.py, and
wigner.py. I discovered that in the demos but didn't file a bug report
since it's a quick fix (let me know if I should).

Paul Nation

unread,
May 12, 2012, 1:31:44 AM5/12/12
to qu...@googlegroups.com
Andy,

Glad to hear you got it working. Another possibility is to run the setup.py file from the EPD iPython command line:

run setup.py install

if you still need sudo, then running ipython with sudo will do the trick. But your correct, it is much easier to use the repositories.

Also, the factorial issue was resolved some time ago. They moved the function to misc, but maybe our flag is set wrong for older versions of scipy. I will check this later today.

Regards,

Paul

Andrew Dawes

unread,
May 12, 2012, 10:23:18 AM5/12/12
to qu...@googlegroups.com
It turns out both suggestions work after all. I hadn't removed the original .so files so they were always "up-to-date" and never rebuilt. From a freshly unzipped install tree I just needed to run setup.py from the correct EPD python.

Nothing strange after all, just an early mistake that I never fully un-did.

> Also, the factorial issue was resolved some time ago. They moved the function to misc, but maybe our flag is set wrong for older versions of scipy. I will check this later today.
>

I saw the release note about factorial being moved to misc so I figured it was a known issue. For what it's worth, clebsch.py had "from scipy.misc import factorial" but the others didn't import factorial explicitly.

>>
>> PS - To fix an error calling the "factorial" function, I had to
>> explicitly import that from scipy.misc in orbital.py, states.py, and
>> wigner.py.

All good here, I'm off to play with this awesome toolbox!

-A
Reply all
Reply to author
Forward
0 new messages