{"action":"created","issue":{"url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/1541","labels_url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/1541/labels{/name}","comments_url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/1541/comments","events_url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/1541/events","html_url":"https://github.com/pyinstaller/pyinstaller/issues/1541","id":108550818,"number":1541,"title":"RuntimeWarning: Parent module 'pyi_hook' not found while handling absolute import","user":{"login":"htgoebel","id":784161,"avatar_url":"https://avatars.githubusercontent.com/u/784161?v=3","gravatar_id":"","url":"https://api.github.com/users/htgoebel","html_url":"https://github.com/htgoebel","followers_url":"https://api.github.com/users/htgoebel/followers","following_url":"https://api.github.com/users/htgoebel/following{/other_user}","gists_url":"https://api.github.com/users/htgoebel/gists{/gist_id}","starred_url":"https://api.github.com/users/htgoebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htgoebel/subscriptions","organizations_url":"https://api.github.com/users/htgoebel/orgs","repos_url":"https://api.github.com/users/htgoebel/repos","events_url":"https://api.github.com/users/htgoebel/events{/privacy}","received_events_url":"https://api.github.com/users/htgoebel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pyinstaller/pyinstaller/labels/@medium","name":"@medium","color":"FFD07D"},{"url":"https://api.github.com/repos/pyinstaller/pyinstaller/labels/hooks","name":"hooks","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pyinstaller/pyinstaller/milestones/11","html_url":"https://github.com/pyinstaller/pyinstaller/milestones/PyInstaller%203.1","labels_url":"https://api.github.com/repos/pyinstaller/pyinstaller/milestones/11/labels","id":1290827,"number":11,"title":"PyInstaller 3.1","description":"* close all feature- and enhancement-requests known at the time 3.0 was released\r\n* clean up the code base (which seams to be necessary after integrating modulegraph)\r\n* update manual and explain better how !PyInstaller works internally.","creator":{"login":"htgoebel","id":784161,"avatar_url":"https://avatars.githubusercontent.com/u/784161?v=3","gravatar_id":"","url":"https://api.github.com/users/htgoebel","html_url":"https://github.com/htgoebel","followers_url":"https://api.github.com/users/htgoebel/followers","following_url":"https://api.github.com/users/htgoebel/following{/other_user}","gists_url":"https://api.github.com/users/htgoebel/gists{/gist_id}","starred_url":"https://api.github.com/users/htgoebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htgoebel/subscriptions","organizations_url":"https://api.github.com/users/htgoebel/orgs","repos_url":"https://api.github.com/users/htgoebel/repos","events_url":"https://api.github.com/users/htgoebel/events{/privacy}","received_events_url":"https://api.github.com/users/htgoebel/received_events","type":"User","site_admin":false},"open_issues":91,"closed_issues":6,"state":"open","created_at":"2015-09-04T16:32:45Z","updated_at":"2015-09-27T17:56:58Z","due_on":"2015-12-30T23:00:00Z","closed_at":null},"comments":1,"created_at":"2015-09-27T17:56:54Z","updated_at":"2015-09-27T18:09:25Z","closed_at":null,"body":"Whenever a hook is executed, I get this error message from within the hook::\r\n```\r\nINFO: Processing hook   hook-encodings.py\r\n.../pyinstaller/PyInstaller/hooks/hook-encodings.py:11: RuntimeWarning: Parent module\r\n'pyi_hook' not found while handling absolute import\r\n  from PyInstaller.utils.hooks import collect_submodules\r\nDEBUG: Collecting submodules for encodings\r\n```\r\n\r\nI also get this for other import types, e.g. `Parent module 'pyi_pre_find_module_path' not found while handling absolute import`.\r\n\r\nThis occurs when the hook is loaded and executed via `importlib_load_source`. I assume, it is related to #1537 and #1538 and caused by changing the working directory."},"comment":{"url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/comments/143581746","html_url":"https://github.com/pyinstaller/pyinstaller/issues/1541#issuecomment-143581746","issue_url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/1541","id":143581746,"user":{"login":"codewarrior0","id":307683,"avatar_url":"https://avatars.githubusercontent.com/u/307683?v=3","gravatar_id":"","url":"https://api.github.com/users/codewarrior0","html_url":"https://github.com/codewarrior0","followers_url":"https://api.github.com/users/codewarrior0/followers","following_url":"https://api.github.com/users/codewarrior0/following{/other_user}","gists_url":"https://api.github.com/users/codewarrior0/gists{/gist_id}","starred_url":"https://api.github.com/users/codewarrior0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codewarrior0/subscriptions","organizations_url":"https://api.github.com/users/codewarrior0/orgs","repos_url":"https://api.github.com/users/codewarrior0/repos","events_url":"https://api.github.com/users/codewarrior0/events{/privacy}","received_events_url":"https://api.github.com/users/codewarrior0/received_events","type":"User","site_admin":false},"created_at":"2015-09-27T18:09:25Z","updated_at":"2015-09-27T18:09:25Z","body":"This is because the call to `importlib_load_source` uses a dotted module name for the new module's name:\r\n\r\n```\r\nself._module = importlib_load_source('pyi_hook.'+self._name, self._filename)\r\n```\r\n\r\nThe dotted module name makes the import machinery think there is a package module called `pyi_hook`. It should be enough to change the module name to e.g. `'pyi_hook_`+self._name."}}