IPython - Enhanced Interactive Python

Improve absolute import management for iptest.py

Reported by Fernando Perez on 2010-01-11
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fernando Perez

Bug Description

On Mon, Jan 11, 2010 at 11:36 AM, Jörgen Stenarson <email address hidden> wrote:
> I often run IPython/testing/iptest.py as a script but this is not possible
> now due to a relative import:
> C:\python\external\ipython-perez\IPython>python testing\iptest.py
> Traceback (most recent call last):
> File "testing\iptest.py", line 39, in <module>
> from . import globalipapp
> ValueError: Attempted relative import in non-package

Argh, yes. This is unfortunately only fixed for 2.6:


We might just add that boilerplate

if __name__ == "__main__" and __package__ is None:
    __package__ = "expected.package.name"

protected by a version check, so your approach continues to work.

Changed in ipython:
assignee: nobody → Fernando Perez (fdo.perez)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers