[Bf-python] python relative imports

HartsAntler goatman.py at gmail.com
Sat Sep 3 00:34:18 CEST 2011


Hi Vaclav,
I was having the same problem, this can fix it.

## make sure we can import from same directory ##
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
if SCRIPT_DIR not in sys.path: sys.path.append( SCRIPT_DIR )



On Fri, Sep 2, 2011 at 3:31 PM, Vaclav Klecanda <vencax77 at gmail.com> wrote:

> Hi all,
> I have faced some problems with relative imports. I have blender 2.59 ->
> python 3. I have following structure of packages:
>
> io_export_dxf:
> ....model:
> ........dxfLibrary.py
> ........migiusModel.py
>
> In migiusModel I would like import dxfLibrary:
>
> try:
>     import dxfLibrary as DXF
> except Exception:
>     raise Exception("No dxfLibrary.py module")
>
> but I get the exception ...
>
> Maybe I am doing something wrong, because I am new to Python3 but IMHO
> there are not much changes.
> Another issue: if I use following syntax: except Exception, p:
> when I want to have the excp object I get InvalidSyntaxError.
>
> Does anybody face similar problems? Is there any source related to this in
> wiki?
>
> thanks VAsek
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20110903/bd5a55d7/attachment.html>


More information about the Bf-python mailing list