{"id":116,"date":"2014-05-05T18:23:33","date_gmt":"2014-05-06T01:23:33","guid":{"rendered":"https:\/\/www.falatic.com\/?p=116"},"modified":"2014-05-05T18:23:33","modified_gmt":"2014-05-06T01:23:33","slug":"python-pyreadline-2-0-bizarre-errors-on-windows-resolved","status":"publish","type":"post","link":"https:\/\/www.falatic.com\/index.php\/116\/python-pyreadline-2-0-bizarre-errors-on-windows-resolved","title":{"rendered":"Python: pyreadline 2.0 bizarre errors on Windows &#8211; resolved!"},"content":{"rendered":"<p>I was fiddling with\u00a0Python and iPython today on Windows (64-bit installs) and tried the <em>help(&#8216;modules&#8217;)<\/em> command in Idle. Surprisingly, it threw an infinite raft of errors from pyreadline, all of the form:<\/p>\n<pre>ArgumentError: argument 2: &lt;type 'exceptions.TypeError'&gt;: expected LP_CONSOLE_SCREEN_BUFFER_INFO instance instead of pointer to CONSOLE_SCREEN_BUFFER_INFO\r\nReadline internal error\r\nTraceback (most recent call last):\r\n File \"C:\\Python27\\lib\\site-packages\\pyreadline\\console\\console.py\", line 768, in hook_wrapper_23\r\n res = ensure_str(readline_hook(prompt))\r\n File \"C:\\Python27\\lib\\site-packages\\pyreadline\\rlmain.py\", line 569, in readline\r\n self.readline_setup(prompt)\r\n File \"C:\\Python27\\lib\\site-packages\\pyreadline\\rlmain.py\", line 565, in readline_setup\r\n self._print_prompt()\r\n File \"C:\\Python27\\lib\\site-packages\\pyreadline\\rlmain.py\", line 466, in _print_prompt\r\n x, y = c.pos()\r\n File \"C:\\Python27\\lib\\site-packages\\pyreadline\\console\\console.py\", line 261, in pos\r\n self.GetConsoleScreenBufferInfo(self.hout, byref(info))<\/pre>\n<p>I took this as a bad sign&#8230;<\/p>\n<p><!--more-->Normally I install Python binaries from <a href=\"http:\/\/www.lfd.uci.edu\/~gohlke\/pythonlibs\/\" target=\"_blank\">LFD&#8217;s &#8220;Unofficial Windows Binaries for Python Extension Packages&#8221;<\/a> site.\u00a0I dug around\u00a0and found there was a <a href=\"https:\/\/github.com\/pyreadline\/pyreadline\/issues\/21\" target=\"_blank\">very similar bug reported and fixed but never actually merged to the pyreadline <\/a><span style=\"text-decoration: underline;\">master branch<\/span>\u00a0&#8211; too bad, since it&#8217;s pretty much hosed for certain uses without this fix. The binary from LFD (or built as part of a pip install)\u00a0faithfully contains this\u00a0bug, so I rebuilt and reinstalled a fixed\u00a0binary by doing the following:<\/p>\n<ul>\n<li>Clone the git repo\u00a0<strong><a href=\"https:\/\/github.com\/kivhift\/pyreadline\" target=\"_blank\">https:\/\/github.com\/kivhift\/pyreadline<\/a><\/strong><\/li>\n<li>Check out the branch <strong>argtypes-cleanup<\/strong><\/li>\n<li>Run <em>buildit.bat<\/em>\n<ul>\n<li>Not sure what the prerequisites are for this but I happened to have <a href=\"http:\/\/tdm-gcc.tdragon.net\/\" target=\"_blank\">TDM&#8217;s gcc<\/a>\u00a0and other compilers\u00a0installed already<\/li>\n<\/ul>\n<\/li>\n<li>Install <em>dist\/pyreadline-2.0.&lt;yourplatform&gt;.exe<\/em><\/li>\n<li>Note when installing this, it may present you with multiple Python installs to install for. Since I have Pythons 2.7 (64-bit) and 3.4 (64-bit) I installed it once for each<\/li>\n<\/ul>\n<p>Once I installed my build of that\u00a0fix branch, the\u00a0module worked correctly and stopped\u00a0spewing errors. Thanks to <a href=\"https:\/\/github.com\/kivhift\" target=\"_blank\">kivhift<\/a> for taking the\u00a0time to track down and fix this vexing\u00a0bug!<\/p>\n<!-- wpsso rrssb get buttons: buttons on archive option not enabled -->\n","protected":false},"excerpt":{"rendered":"<p>I was fiddling with\u00a0Python and iPython today on Windows (64-bit installs) and tried the help(&#8216;modules&#8217;) command in Idle. Surprisingly, it threw an infinite raft of errors from pyreadline, all of <a href=\"https:\/\/www.falatic.com\/index.php\/116\/python-pyreadline-2-0-bizarre-errors-on-windows-resolved\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[86],"tags":[],"class_list":["entry","author-marty","has-more-link","post-116","post","type-post","status-publish","format-standard","category-software-and-hardware-development"],"_links":{"self":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":0,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}