I am trying to run the thrift tutorial for python. But when I try to run PythonServer.py
, I get this error:
Traceback (most recent call last):
File "./PythonServer.py", line 24, in <module>
sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0])
IndexError: list index out of range
How can I fix this?
Each Thrift-based application typically consists of three pieces, which are all needed to make a properly functioning whole:
Regardless whether you unpack the runtime package from the download section of the web site, or clone Thrift from source, you always get a folder structure similar to this1):
/
|- lib
| |- cpp
| |- java
| |- py
| +- ... more languages ...
|
+- tutorial
|- cpp
|- java
|- py
+- ... more languages ...
Both folders lib
and tutorial
contain subdirectories for each language. And that's the reason why the tutorial refers to a relative path that is supposed to house the Python Thrift runtime files.
Consequently, you either want to replicate that same folder structure (e.g. by directly using the tutorial code from the package), or alternatively change the directory reference to point to the folder where your Python Thrift runtime files actually are located.
1) In reality, you get a whole lot more folders, but these are not important here so we simply ignore them.