Error Import Impyla library on Windows
<p>I'm having trouble with using impyla library on windows</p>

<p>I installed impyla library </p>

<p><code>pip install impyla</code></p>

<p>Error occured when I tried to import impyla libary in python code</p>

<pre><code>from impala.dbapi import connect  # error occured
from impala.util import as_pandas
conn = connect(host='10.xx.xx.xx', database='xx_xx', port=21050)`
</code></pre>

<blockquote>
  <p>Traceback (most recent call last): ...</p>
  
  <p>File "D:/test/test.py", line 14, in 
      <strong>from impala.dbapi import connect</strong></p>
  
  <p>File "C:\Anaconda3\lib\site-packages\impala\dbapi.py", line 28, in 
      <strong>import impala.hiveserver2 as hs2</strong></p>
  
  <p>File "C:\Anaconda3\lib\site-packages\impala\hiveserver2.py", line 32, in 
      <strong>from impala._thrift_api import (</strong></p>
  
  <p>File "C:\Anaconda3\lib\site-packages\impala_thrift_api.py", line 73, in 
      <strong>include_dirs=[thrift_dir])</strong></p>
  
  <p>File "C:\Anaconda3\lib\site-packages\thriftpy\parser__init__.py", line 30, in load
      <strong>include_dir=include_dir)</strong></p>
  
  <p>File "C:\Anaconda3\lib\site-packages\thriftpy\parser\parser.py", line 496, in parse
      url_scheme))</p>
  
  <p><strong>thriftpy.parser.exc.ThriftParserError: ThriftPy does not support generating module with path in protocol 'c'</strong></p>
</blockquote>

<p>when I tried to print include_dir, which was </p>

<p><code>D:/test\thrift</code></p>

<p>I just cannot import libray at all</p>

<p>help me</p>

<p>I had the same problem with thriftpy, the problem on windows is an absolute path is like <strong>C:\foo\bar.thrift</strong> </p>

<p>But, the way the thrift library parses the file, it detects the <strong>C:</strong> as if it were a protocol like <strong>http:</strong> or <strong>https:</strong>  </p>

<p>Its pretty easy to workaround you just have to strip the first two characters from the path with a slice like <strong>path[2:]</strong></p>

<p>Just slice when you call <code>thriftpy.load</code> or in the library file </p>

<pre><code>File "C:\Anaconda3\lib\site-packages\thriftpy\parser__init__.py", line 30

path = "C:\foo\bar.thrift"
thrift.load(path[2:], module_name, include_dirs=include_dirs,
                   include_dir=include_dir)
</code></pre>

<p><strong>OR</strong> </p>

<p>You can go a bit deeper and make the same change that I already submitted as a patch on the <a href="https://github.com/eleme/thriftpy/pull/236" rel="nofollow">github page</a>... perhaps it will be incorporated in the next version of thrift. </p>

<pre><code>File "C:\Anaconda3\lib\site-packages\thriftpy\parser\parser.py", line 488

-    if url_scheme == '':
+    if len(url_scheme) &lt;= 1:
</code></pre>

<p>My justification of why this change is valid is in the pull request. If its incorporated then you wont have to worry about making the same change again when you update the library. If not then just strip the two characters again.  </p>

python windows impyla