python:导入libpci会引发SyntaxError

时间:2016-10-17 10:45:24

标签: python python-2.7

我刚刚在我的机器上安装了libpci:

$ pip2.7 install libpci

试图运行:

#!/usr/local/bin/python2.7
import libpci

print('hello libpci')

但是这会引发以下语法错误:

Traceback (most recent call last):
  File "./test.py", line 2, in <module>
    import libpci
  File "/usr/local/lib/python2.7/site-packages/libpci/__init__.py", line 26, in <module>
    from libpci.wrapper import LibPCI
  File "/usr/local/lib/python2.7/site-packages/libpci/wrapper.py", line 26, in <module>
    from libpci._functions import pci_alloc
  File "/usr/local/lib/python2.7/site-packages/libpci/_functions.py", line 39
    def pci_alloc() -> ctypes.POINTER(pci_access):
                    ^
SyntaxError: invalid syntax

如何在libpci中引发SyntaxError?
是因为我错过了一些依赖吗?

1 个答案:

答案 0 :(得分:3)

libpci project需要Python 3.4或更高版本。从项目标签:

Categories
[...]
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4

引发语法错误,因为项目使用{3}}(Python 3功能)配置ctypes图层,请参阅annotations