Python libusb pyusb“mach-o,但架构错误”

发布于 2024-09-05 13:24:08 字数 1242 浏览 0 评论 0原文

我在使用 pyusb 模块时遇到一些问题。我已将问题范围缩小到一行,并创建了一个小示例脚本来复制错误。

#!/usr/bin/env python
"""
This module was created to isolate the problem in the pyusb package.

Operating system:  Mac OS 10.6.3

Python Version: 2.6.4

libusb 1.0.8 has been successfully installed using:
sudo port install libusb

I have also tried modifying /opt/local/etc/macports/macports.conf to force
the i386 architecture instead of x86_64.
"""
from ctypes import *
import ctypes.util

libname = ctypes.util.find_library('usb-1.0')
print 'libname: ', libname
l = CDLL(libname, RTLD_GLOBAL)

# RESULT:
#libname:  /usr/local/lib/libusb-1.0.dylib
#Traceback (most recent call last):
#  File "./pyusb_problem.py", line 7, in <module>
#    l = CDLL(libname, RTLD_GLOBAL)
#  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 353, in __init__
#    self._handle = _dlopen(self._name, mode)
#OSError: dlopen(/usr/local/lib/libusb-1.0.dylib, 10): no suitable image found.  Did find:
# /usr/local/lib/libusb-1.0.dylib: mach-o, but wrong architecture

# End of File

同样的脚本在 Ubuntu 10.04 上成功运行。

我尝试为 32 位(i386)而不是 x86_64(操作系统 10.6 的默认值)构建 libusb 模块(直接从源代码和通过 macports),但我收到相同的错误。

预先感谢您的帮助!

I am having some trouble with the pyusb module. I have narrowed down the problem to a single line, and have created a small example script to replicate the error.

#!/usr/bin/env python
"""
This module was created to isolate the problem in the pyusb package.

Operating system:  Mac OS 10.6.3

Python Version: 2.6.4

libusb 1.0.8 has been successfully installed using:
sudo port install libusb

I have also tried modifying /opt/local/etc/macports/macports.conf to force
the i386 architecture instead of x86_64.
"""
from ctypes import *
import ctypes.util

libname = ctypes.util.find_library('usb-1.0')
print 'libname: ', libname
l = CDLL(libname, RTLD_GLOBAL)

# RESULT:
#libname:  /usr/local/lib/libusb-1.0.dylib
#Traceback (most recent call last):
#  File "./pyusb_problem.py", line 7, in <module>
#    l = CDLL(libname, RTLD_GLOBAL)
#  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 353, in __init__
#    self._handle = _dlopen(self._name, mode)
#OSError: dlopen(/usr/local/lib/libusb-1.0.dylib, 10): no suitable image found.  Did find:
# /usr/local/lib/libusb-1.0.dylib: mach-o, but wrong architecture

# End of File

This same script runs on Ubuntu 10.04 successfully.

I have tried building the libusb module (directly from source AND through macports) for 32-bit (i386) instead of x86_64 (default for OS 10.6), but I receive the same error.

Thank-you in advance for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文