gpt4 book ai didi

python - 在 python 中导入 hid 会导致错误 "hid.so: undefined symbol: libusb_open"

转载 作者:行者123 更新时间:2023-12-01 05:56:48 27 4
gpt4 key购买 nike

我正在尝试安装 cython-hidapi 以在 Ubuntu 12.04 上读取 USB。我已按照 https://github.com/gbishop/cython-hidapi 的说明进行操作并安装了以下版本:

  • lib-usb == 1.0.9
  • hidapi == 0.7.0
  • cython == 0.16
  • Python == 2.7
  • 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

有谁知道我为什么收到此错误以及如何检查/处理它?<​​/p>

谢谢!沃特

最佳答案

过去一周我一直在努力解决这个完全相同的问题。幸运的是,我的一位非常了解 Cython 世界的 friend 能够提供帮助。您需要更改 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 获取零钱.

关于python - 在 python 中导入 hid 会导致错误 "hid.so: undefined symbol: libusb_open",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12140859/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com