[Cython] help tracking down TypeError
Robert Kern
robert.kern at gmail.com
Wed Nov 12 02:19:44 CET 2008
Hoyt Koepke wrote:
> Hello,
>
> I've got a fairly large cython module that I've just made a lot of
> changes to. It compiles fine, but when I try to import it, it just
> gives this cryptic error message:
>
>
> TypeError: Item in ``from list'' not a string
>
>
> Here's the traceback:
>
>
> In [1]: import geometry
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
>
> /home/hoytak/workspace/gravimetrics/spatial/<ipython console> in <module>()
>
> /home/hoytak/workspace/gravimetrics/spatial/geometry.pyx in
> spatial.geometry (spatial/geometry.c:6001)()
> 2
> 3
> ----> 4 import numpy.random as rn
> 5 from copy import copy
> 6
>
> TypeError: Item in ``from list'' not a string
>> /home/hoytak/workspace/gravimetrics/spatial/geometry.pyx(4)spatial.geometry (spatial/geometry.c:6001)()
> 3
> ----> 4 import numpy.random as rn
> 5 from copy import copy
>
>
>
> I'm pretty sure that it doesn't have anything to do with the line in
> question, as changing/removing it doesn't change things.
Are you sure? I changed the line to this:
from numpy import random as rn
And it worked with Cython 0.10. Possibly the code that handles "import
<foo>.<bar> as <baz>" is incorrect. It's a tricky bit of syntax.
Stylistically, though, I would suggest just doing "from numpy import random".
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Cython-dev
mailing list