{"action":"created","issue":{"url":"https://api.github.com/repos/BurntSushi/pdoc/issues/94","repository_url":"https://api.github.com/repos/BurntSushi/pdoc","labels_url":"https://api.github.com/repos/BurntSushi/pdoc/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/BurntSushi/pdoc/issues/94/comments","events_url":"https://api.github.com/repos/BurntSushi/pdoc/issues/94/events","html_url":"https://github.com/BurntSushi/pdoc/issues/94","id":131242800,"number":94,"title":"SystemError: Parent module '' not loaded, cannot perform relative import","user":{"login":"dossan","id":9349000,"avatar_url":"https://avatars.githubusercontent.com/u/9349000?v=3","gravatar_id":"","url":"https://api.github.com/users/dossan","html_url":"https://github.com/dossan","followers_url":"https://api.github.com/users/dossan/followers","following_url":"https://api.github.com/users/dossan/following{/other_user}","gists_url":"https://api.github.com/users/dossan/gists{/gist_id}","starred_url":"https://api.github.com/users/dossan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dossan/subscriptions","organizations_url":"https://api.github.com/users/dossan/orgs","repos_url":"https://api.github.com/users/dossan/repos","events_url":"https://api.github.com/users/dossan/events{/privacy}","received_events_url":"https://api.github.com/users/dossan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-02-04T04:48:55Z","updated_at":"2016-02-05T00:09:30Z","closed_at":null,"body":"I am trying to create a html documentation for a module with the following command:\r\n\r\n    pdoc --html --overwrite huffman.py \r\n\r\nBut I am receiving the following error:\r\n\r\n    Traceback (most recent call last):\r\n      File \"/Library/Frameworks/Python.framework/Versions/3.5/bin/pdoc\", line 458, in <module>\r\n        module = imp.load_source('__pdoc_file_module__', fp, f)\r\n      File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py\", line 172, in load_source\r\n        module = _load(spec)\r\n      File \"<frozen importlib._bootstrap>\", line 693, in _load\r\n      File \"<frozen importlib._bootstrap>\", line 673, in _load_unlocked\r\n      File \"<frozen importlib._bootstrap_external>\", line 662, in exec_module\r\n      File \"<frozen importlib._bootstrap>\", line 222, in _call_with_frames_removed\r\n      File \"/Users/cell/Desktop/ands/algorithms/greedy/huffman.py\", line 56, in <module>\r\n        from ...ds.MinPriorityQueue import *\r\n    SystemError: Parent module '' not loaded, cannot perform relative import    \r\n\r\nI know that the problem is related to the fact that I am doing a relative import, which doesn't work because `huffman.py` is not being imported as I programmed it to be imported. So, currently, I am using the following code:\r\n\r\n    if __name__ == \"__main__\":\r\n        from os import path, sys\r\n        BASE_DIR = path.dirname(path.dirname(path.dirname(__file__)))  # ands\r\n        sys.path.append(BASE_DIR)\r\n        from ds.MinPriorityQueue import *\r\n    else:\r\n            from ...ds.MinPriorityQueue import *\r\n\r\nWhich is already a mess, because I am trying to handle both when this `huffman.py` file (or module) is run as main or imported from outside `ands`, which is the parent of the parent of  the package where `huffman.py` is situated. To solve the problem, I did the following:\r\n\r\n    from os import path, sys\r\n    BASE_DIR = path.dirname(path.dirname(path.dirname(__file__)))  # ands\r\n    sys.path.append(BASE_DIR)\r\n\r\n    if __name__ == \"__main__\":\r\n        from ds.MinPriorityQueue import *\r\n    else:\r\n        try:\r\n            from ...ds.MinPriorityQueue import *\r\n        except SystemError:\r\n            from ds.MinPriorityQueue import *\r\n\r\nUnfortunately this is far from being simple, considered that what I want to achieve should be very simple.\r\n\r\nAny suggestions to simplify my code?"},"comment":{"url":"https://api.github.com/repos/BurntSushi/pdoc/issues/comments/180115229","html_url":"https://github.com/BurntSushi/pdoc/issues/94#issuecomment-180115229","issue_url":"https://api.github.com/repos/BurntSushi/pdoc/issues/94","id":180115229,"user":{"login":"BurntSushi","id":456674,"avatar_url":"https://avatars.githubusercontent.com/u/456674?v=3","gravatar_id":"","url":"https://api.github.com/users/BurntSushi","html_url":"https://github.com/BurntSushi","followers_url":"https://api.github.com/users/BurntSushi/followers","following_url":"https://api.github.com/users/BurntSushi/following{/other_user}","gists_url":"https://api.github.com/users/BurntSushi/gists{/gist_id}","starred_url":"https://api.github.com/users/BurntSushi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BurntSushi/subscriptions","organizations_url":"https://api.github.com/users/BurntSushi/orgs","repos_url":"https://api.github.com/users/BurntSushi/repos","events_url":"https://api.github.com/users/BurntSushi/events{/privacy}","received_events_url":"https://api.github.com/users/BurntSushi/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T00:09:30Z","updated_at":"2016-02-05T00:09:30Z","body":"@dossan No problem, good luck. I wish you the best!"}}