{"action":"created","issue":{"url":"https://api.github.com/repos/Kitt-AI/snowboy/issues/316","repository_url":"https://api.github.com/repos/Kitt-AI/snowboy","labels_url":"https://api.github.com/repos/Kitt-AI/snowboy/issues/316/labels{/name}","comments_url":"https://api.github.com/repos/Kitt-AI/snowboy/issues/316/comments","events_url":"https://api.github.com/repos/Kitt-AI/snowboy/issues/316/events","html_url":"https://github.com/Kitt-AI/snowboy/issues/316","id":276833590,"node_id":"MDU6SXNzdWUyNzY4MzM1OTA=","number":316,"title":"[Python3]SystemError: Parent module '' not loaded, cannot perform relative import","user":{"login":"chandong83","id":4668984,"node_id":"MDQ6VXNlcjQ2Njg5ODQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4668984?v=4","gravatar_id":"","url":"https://api.github.com/users/chandong83","html_url":"https://github.com/chandong83","followers_url":"https://api.github.com/users/chandong83/followers","following_url":"https://api.github.com/users/chandong83/following{/other_user}","gists_url":"https://api.github.com/users/chandong83/gists{/gist_id}","starred_url":"https://api.github.com/users/chandong83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chandong83/subscriptions","organizations_url":"https://api.github.com/users/chandong83/orgs","repos_url":"https://api.github.com/users/chandong83/repos","events_url":"https://api.github.com/users/chandong83/events{/privacy}","received_events_url":"https://api.github.com/users/chandong83/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-11-26T15:39:15Z","updated_at":"2018-08-21T16:53:40Z","closed_at":null,"author_association":"NONE","body":"I tried it with python 3 on raspberry pi.\r\n\r\nand I get the following error:\r\n<pre>\r\nTraceback (most recent call last):\r\nFile \"demo.py\", line 1, in <module>\r\nimport snowboydecoder\r\nFile \"/home/pi/snowboy/examples/Python3/snowboydecoder.py\", line 5, in <module>\r\nfrom . import snowboydetect\r\nSystemError: Parent module '' not loaded, cannot perform relative import\r\n</pre>\r\n\r\nI changed it as follows.\r\n<pre>\r\nin snowboy/examples/Python3/snowboydecoder.py\r\n</pre>\r\n\r\n<pre>\r\n<code>\r\nfrom . import snowboydetect\r\nto \r\nimport snowboydetect\r\n</code>\r\n</pre>\r\n\r\nit is working.\r\nbut This way is not good for that project.\r\n\r\nso How about the following?\r\n<pre>\r\n<code>\r\n\r\nfrom os.path import dirname\r\n# get the current path.\r\ncurpath = dirname(__file__)\r\n\r\nimport imp\r\nsnowboydetect = imp.load_source('snowboydetect', curpath+'/snowboydetect.py')\r\n</code>\r\n</pre>\r\n\r\nThank you for Good project"},"comment":{"url":"https://api.github.com/repos/Kitt-AI/snowboy/issues/comments/414744809","html_url":"https://github.com/Kitt-AI/snowboy/issues/316#issuecomment-414744809","issue_url":"https://api.github.com/repos/Kitt-AI/snowboy/issues/316","id":414744809,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDc0NDgwOQ==","user":{"login":"fl118543","id":16203660,"node_id":"MDQ6VXNlcjE2MjAzNjYw","avatar_url":"https://avatars1.githubusercontent.com/u/16203660?v=4","gravatar_id":"","url":"https://api.github.com/users/fl118543","html_url":"https://github.com/fl118543","followers_url":"https://api.github.com/users/fl118543/followers","following_url":"https://api.github.com/users/fl118543/following{/other_user}","gists_url":"https://api.github.com/users/fl118543/gists{/gist_id}","starred_url":"https://api.github.com/users/fl118543/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fl118543/subscriptions","organizations_url":"https://api.github.com/users/fl118543/orgs","repos_url":"https://api.github.com/users/fl118543/repos","events_url":"https://api.github.com/users/fl118543/events{/privacy}","received_events_url":"https://api.github.com/users/fl118543/received_events","type":"User","site_admin":false},"created_at":"2018-08-21T16:53:40Z","updated_at":"2018-08-21T16:53:40Z","author_association":"NONE","body":"The module imp is deprecated since Pÿthon 3.4 so if you want to use a later version of python you should use the importlib module. You'll have to modify snowboydecoder and replace \"from . import snowboydetect\" by:\r\n\r\nimport importlib\r\nimportlib.import_module(\"snowboydetect\")\r\n\r\n### Example:\r\n**Before the modification:**\r\n\r\n$ python3 demo4.py \r\nTraceback (most recent call last):\r\n  File \"demo4.py\", line 1, in <module>\r\n    import snowboydecoder\r\n  File \"/home/francois/DEV/Android_apk/snowboy/examples/Python3/snowboydecoder.py\", line 7, in <module>\r\n    from . import snowboydetect\r\nImportError: attempted relative import with no known parent package\r\n\r\n**After the modification:**\r\n\r\n$ python3 demo4.py \r\nError: need to specify model name\r\nUsage: python demo.py your.model\r\n\r\nHope this help,\r\nFrancois\r\n\r\n"}}
{"actor":{"display_login":"fl118543"}}