我正在尝试安装cython-hidapi来读取我的Ubuntu 12.04上的USB。我按照https://github.com/gbishop/cython-hidapi的说明操作并安装了以下版本:
当我从安装执行测试部分(python> import hid)时,我收到以下错误:
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/local/lib/python2.7/dist-packages/hid.so: undefined symbol: libusb_open
有谁知道为什么我收到此错误以及要检查/做些什么?
谢谢! Wout
答案 0 :(得分:2)
过去一周,我一直在努力解决这个问题。幸运的是,我的一位非常了解Cython世界的朋友能够提供帮助。您需要更改setup.py中的setup(...)函数,如下所示:
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("hid", ["hid.pyx", "hid-libusb.c"],
libraries=["usb-1.0", "udev", "rt"])]
)
我不知道其他发行版是否会有轻微的差异,但这已经在Ubuntu 12.04和Debian 0.1.12上进行了测试。使用回复原始帖子的建议来确定正确的链接器标志(LDFLAGS)和libraries=
行。
已向维护者提交了pull request。您也可以从fork获取更改。