bogus "relative import" failure with Cython3/Python3

92 views
Skip to first unread message

Guy Streeter

unread,
Aug 19, 2014, 4:31:06 PM8/19/14
to cython...@googlegroups.com
My .pxy file imports an external python module. This works fine on Cython/Python2, but on 3 I get:

SystemError: Parent module '' not loaded, cannot perform relative import

but this is not a relative import. Anybody else see this happen?

thanks,
--Guy

Robert Bradshaw

unread,
Aug 19, 2014, 5:07:38 PM8/19/14
to cython...@googlegroups.com
Do you have a pointer to some code where this is not working?

Guy Streeter

unread,
Aug 20, 2014, 3:20:20 PM8/20/14
to cython...@googlegroups.com
While trying to create a simple example of this problem, I narrowed it down to not having an __init__.py in my package directory. In my testing, I would just point PYTHONPATH at the package directory, and that works with 2 but fails with 3.
Some difference there between the two versions that I don't understand.

--Guy

Chris Barker

unread,
Aug 20, 2014, 4:32:38 PM8/20/14
to cython-users
On Wed, Aug 20, 2014 at 12:20 PM, Guy Streeter <guy.st...@gmail.com> wrote:
While trying to create a simple example of this problem, I narrowed it down to not having an __init__.py in my package directory.

well, if it doesn't have an __init__.py, then it isn't a package. And it it isn't a package, you can't relative import in it -- so this makes sense. 

IIRC, py3 tightened up the relative import system.

-CHB



 
In my testing, I would just point PYTHONPATH at the package directory, and that works with 2 but fails with 3.
Some difference there between the two versions that I don't understand.

--Guy

On Tuesday, August 19, 2014 4:07:38 PM UTC-5, Robert Bradshaw wrote:
On Tue, Aug 19, 2014 at 1:31 PM, Guy Streeter <guy.st...@gmail.com> wrote:
> My .pxy file imports an external python module. This works fine on
> Cython/Python2, but on 3 I get:
>
> SystemError: Parent module '' not loaded, cannot perform relative import
>
> but this is not a relative import. Anybody else see this happen?

Do you have a pointer to some code where this is not working?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov
Reply all
Reply to author
Forward
0 new messages