Python libusb pyusb“有男子气概,但架构错误”

2024-09-24 02:28:00 发布

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

我的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

这个脚本在ubuntu10.04上成功运行。在

我尝试过构建32位(i386)的libusb模块(直接从源代码和macports)而不是x86_64(os10.6的默认值),但是我收到了相同的错误。在

提前感谢您的帮助!在


Tags: 模块thein脚本libusrlocal错误