Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 获得;索引器:列表索引超出范围“;运行thrift示例时出错_Python_Thrift - Fatal编程技术网

Python 获得;索引器:列表索引超出范围“;运行thrift示例时出错

Python 获得;索引器:列表索引超出范围“;运行thrift示例时出错,python,thrift,Python,Thrift,我正在尝试为python运行。但是,当我尝试运行PythonServer.py时,出现以下错误: 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 回溯(最近一次呼叫最

我正在尝试为python运行。但是,当我尝试运行
PythonServer.py
时,出现以下错误:

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
回溯(最近一次呼叫最后一次):
文件“/PythonServer.py”,第24行,在
sys.path.insert(0,glob.glob('../../lib/py/build/lib*')[0])
索引器:列表索引超出范围

如何解决此问题?

每个基于节俭的应用程序通常由三个部分组成,它们都是构成一个正常运行的整体所必需的:

  • 从IDL文件生成的代码(通过Thrift编译器)
  • 特定目标语言的Thrift运行库
  • 为实现服务器和/或客户端逻辑而编写的代码
无论您是从网站的中解包,还是克隆Thrift,您都会得到与此类似的文件夹结构1):

文件夹
lib
tutorial
都包含每种语言的子目录。这就是为什么本教程提到了一个相对路径,它应该包含Python Thrift运行时文件

因此,您要么希望复制相同的文件夹结构(例如,直接使用包中的教程代码),要么更改目录引用以指向Python Thrift运行时文件实际所在的文件夹



1) 实际上,您会得到更多的文件夹,但这些文件夹在这里并不重要,所以我们可以忽略它们。

您能检查一下您是否从这个
glob.glob('../../lib/py/build/lib*')
?如果您的计算机上也存在此路径,@AKS No,“../../lib/py/build/lib*”不存在。我不知道为什么这条路是相对的。
/
|- lib
|   |- cpp
|   |- java
|   |- py
|   +- ... more languages ...
|   
+- tutorial
    |- cpp
    |- java
    |- py
    +- ... more languages ...