在python中导入hid会导致错误“藏起来了:未定义符号:libusb_open“

2024-09-26 22:53:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试安装cythonhidapi来读取我的ubuntu12.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

有没有人知道我为什么会收到这个错误,以及如何检查/处理它?在

谢谢! 不会的


Tags: httpsimport版本githubcomlib错误cython
1条回答
网友
1楼 · 发布于 2024-09-26 22:53:05

在过去的一周里,我一直在为同样的问题而挣扎。幸运的是,我的一个非常了解赛顿世界的朋友能帮上忙。您需要在中更改setup(…)函数设置.py具体如下:

setup(
    cmdclass = {'build_ext': build_ext},
    ext_modules = [Extension("hid", ["hid.pyx", "hid-libusb.c"],
                  libraries=["usb-1.0", "udev", "rt"])]
)

我不知道Ubuntu.0和其他发行版是否有轻微的差异。使用回复原始帖子中的建议来确定正确的链接器标志(LDFLAGS)和libraries=行。在

已将pull request提交给维护人员。你也可以从我的fork那里得到零钱。在

相关问题 更多 >

    热门问题