<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi William,<div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>I would recommend continuing to use relative imports. Assuming you have a folder named 'X' that has a file named 'Y' with a class named 'Z' in it, you would import Z with:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>from .X.Y import Z</div><div class=""><br class=""></div><div class="">Two caveats are:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>(1) Y must have a file names __init__.py in it</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>(2) You might need to import Y first, <i class="">i.e.</i><span style="font-style: normal;" class="">:</span></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>import .X.Y</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>from .X.Y import Z</div><div class=""><br class=""></div><div class=""><div class="">--Eric</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>Eric Pettersen</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>UCSF Computer Graphics Lab</div></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Apr 5, 2022, at 7:33 AM, William Hofsøy via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi, I have been doing some restructuring and refactoring of my project and started having trouble with my imports and modules not being found. previously all my imports were relative for instance: "from . import tool"</div><div class="">However this is a bit impractical now that I have a folder structure, so I have been trying to use absolute imports like from "src.toolname.pythonfile import class" but it seems my folder structure differs from how it is after installing it into ChimeraX. I am using pycharm as my editor and the automatic import paths they set up also fails, meanwhile i looked at the sys.path and there the structure is chimerax/packagename where packagename contains the files contained in my src.</div><div class=""><br class=""></div><div class="">So I was wondering if there is a way to set this up properly?<br class=""></div></div>
_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users<br class=""></div></blockquote></div><br class=""></div></body></html>