{"action":"created","issue":{"url":"https://api.github.com/repos/jupyter-incubator/declarativewidgets/issues/374","repository_url":"https://api.github.com/repos/jupyter-incubator/declarativewidgets","labels_url":"https://api.github.com/repos/jupyter-incubator/declarativewidgets/issues/374/labels{/name}","comments_url":"https://api.github.com/repos/jupyter-incubator/declarativewidgets/issues/374/comments","events_url":"https://api.github.com/repos/jupyter-incubator/declarativewidgets/issues/374/events","html_url":"https://github.com/jupyter-incubator/declarativewidgets/issues/374","id":157380404,"number":374,"title":"Cannot find `bower.cmd` executable under Windows when importing components","user":{"login":"ankostis","id":501585,"avatar_url":"https://avatars.githubusercontent.com/u/501585?v=3","gravatar_id":"","url":"https://api.github.com/users/ankostis","html_url":"https://github.com/ankostis","followers_url":"https://api.github.com/users/ankostis/followers","following_url":"https://api.github.com/users/ankostis/following{/other_user}","gists_url":"https://api.github.com/users/ankostis/gists{/gist_id}","starred_url":"https://api.github.com/users/ankostis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankostis/subscriptions","organizations_url":"https://api.github.com/users/ankostis/orgs","repos_url":"https://api.github.com/users/ankostis/repos","events_url":"https://api.github.com/users/ankostis/events{/privacy}","received_events_url":"https://api.github.com/users/ankostis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-29T10:49:42Z","updated_at":"2016-06-02T16:06:18Z","closed_at":null,"body":"###  Versions:\r\n[WinPython](http://winpython.github.io/): 1.5.1.3\r\nipython: 4.1 \r\ndeclarativewidgets: 0.5.2\r\n[node (portable)](https://sourceforge.net/projects/nodejsportable/): v5.7.0\r\nnpm:3.5.2\r\nbower: 1.7.9\r\n\r\n### Problem:\r\nUnder Windows, when trying to import an external polymer, the kernel fails to locate and launch the `bower` executable, with this error:\r\n```\r\n[E 11:51:02.015 NotebookApp] Uncaught exception POST /urth_import (::1)\r\n    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/urth_import', version='HTTP/1.1', remote_ip='::1', headers={'Host': 'localhost:8888', 'Connection': 'keep-alive', 'Referer': 'http://localhost:8888/notebooks/dice.ipynb', 'Accept-Encoding': 'gzip, deflate', 'Origin': 'http://localhost:8888', 'Accept-Language': 'en-US,en;q=0.8,el;q=0.6', 'Content-Length': '39', 'Dnt': '1', 'Accept': 'application/json', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36', 'Content-Type': 'application/json'})\r\n    Traceback (most recent call last):\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\site-packages\\tornado\\web.py\", line 1445, in _execute\r\n        result = yield result\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\site-packages\\tornado\\gen.py\", line 1008, in run\r\n        value = future.result()\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\site-packages\\tornado\\concurrent.py\", line 232, in result\r\n        raise_exc_info(self._exc_info)\r\n      File \"<string>\", line 3, in raise_exc_info\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\site-packages\\tornado\\gen.py\", line 1014, in run\r\n        yielded = self.gen.throw(*exc_info)\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\site-packages\\urth\\widgets\\ext\\urth_import.py\", line 54, in post\r\n        code = yield self.executor.submit(do_install, package_name=package_name)\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\site-packages\\tornado\\gen.py\", line 1008, in run\r\n        value = future.result()\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\concurrent\\futures\\_base.py\", line 398, in result\r\n        return self.__get_result()\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\concurrent\\futures\\_base.py\", line 357, in __get_result\r\n        raise self._exception\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\concurrent\\futures\\thread.py\", line 55, in run\r\n        result = self.fn(*self.args, **self.kwargs)\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\site-packages\\urth\\widgets\\ext\\urth_import.py\", line 70, in do_install\r\n        cwd=widgets_dir)\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\subprocess.py\", line 579, in check_call\r\n        retcode = call(*popenargs, **kwargs)\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\subprocess.py\", line 560, in call\r\n        with Popen(*popenargs, **kwargs) as p:\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\subprocess.py\", line 950, in __init__\r\n        restore_signals, start_new_session)\r\n      File \"D:\\Apps\\WinPython-64bit-3.5.1.3\\python-3.5.1.amd64\\lib\\subprocess.py\", line 1220, in _execute_child\r\n        startupinfo)\r\n    FileNotFoundError: [WinError 2] The system cannot find the file specified\r\n[E 11:51:02.114 NotebookApp] {\r\n      \"Host\": \"localhost:8888\",\r\n      \"Connection\": \"keep-alive\",\r\n      \"Referer\": \"http://localhost:8888/notebooks/dice.ipynb\",\r\n      \"Accept-Encoding\": \"gzip, deflate\",\r\n      \"Origin\": \"http://localhost:8888\",\r\n      \"Accept-Language\": \"en-US,en;q=0.8,el;q=0.6\",\r\n      \"Content-Length\": \"39\",\r\n      \"Dnt\": \"1\",\r\n      \"Accept\": \"application/json\",\r\n      \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36\",\r\n      \"Content-Type\": \"application/json\"\r\n    }\r\n```\r\n\r\nThis happens because in Windows NodeJS (portable), the `npm install bower` command creates a `bower` and `bower.cmd` in the PATH; they both have no `.exe` extension, so the  [line 70 at urth_import.py](https://github.com/jupyter-incubator/declarativewidgets/blob/master/nb-extension/python/urth/widgets/ext/urth_import.py#L68-L70) fails.\r\n\r\n### Workaround:\r\nOn Windows, npm-installed packages like `bower` have to be invoked through the `cmd.exe` interpreter,\r\nlike that (with some logging enhancements):\r\n```python\r\ndef do_install(package_name):\r\n    logger.info('Installing %r', package_name)\r\n    args = ['bower', 'install', package_name, '--allow-root',\r\n            '--config.interactive=false', '--production', '--quiet']\r\n    if os.name == 'nt':\r\n        args = ['cmd', '/C'] + args\r\n    try:\r\n        subprocess.check_call(args, cwd=widgets_dir)\r\n    except subprocess.CalledProcessError as e:\r\n        logger.error(\"Failed installing %r into %r with cmd: \\n  %s \\n  due to: %s\", package_name, widgets_dir, args, e, exc_info=1)\r\n        return -1\r\n\r\n    return 0\r\n```\r\n\r\nAn alternative workaround would be not to require NodeJS and use a [python bower-like package](https://www.google.com/search?q=python+bower) instead."},"comment":{"url":"https://api.github.com/repos/jupyter-incubator/declarativewidgets/issues/comments/223339667","html_url":"https://github.com/jupyter-incubator/declarativewidgets/issues/374#issuecomment-223339667","issue_url":"https://api.github.com/repos/jupyter-incubator/declarativewidgets/issues/374","id":223339667,"user":{"login":"lbustelo","id":2474841,"avatar_url":"https://avatars.githubusercontent.com/u/2474841?v=3","gravatar_id":"","url":"https://api.github.com/users/lbustelo","html_url":"https://github.com/lbustelo","followers_url":"https://api.github.com/users/lbustelo/followers","following_url":"https://api.github.com/users/lbustelo/following{/other_user}","gists_url":"https://api.github.com/users/lbustelo/gists{/gist_id}","starred_url":"https://api.github.com/users/lbustelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbustelo/subscriptions","organizations_url":"https://api.github.com/users/lbustelo/orgs","repos_url":"https://api.github.com/users/lbustelo/repos","events_url":"https://api.github.com/users/lbustelo/events{/privacy}","received_events_url":"https://api.github.com/users/lbustelo/received_events","type":"User","site_admin":false},"created_at":"2016-06-02T16:06:17Z","updated_at":"2016-06-02T16:06:17Z","body":"@ankostis We will let travis do its thing..."}}
{"actor":{"display_login":"lbustelo"}}