我刚刚在我的机器上安装了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?
是因为我错过了一些依赖吗?
答案 0 :(得分:3)
libpci
project需要Python 3.4或更高版本。从项目标签:
Categories [...] Programming Language :: Python :: 3 Programming Language :: Python :: 3.4
引发语法错误,因为项目使用{3}}(Python 3功能)配置ctypes
图层,请参阅annotations。