2

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!

psmears
  • 26,070
  • 4
  • 40
  • 48
Jon
  • 21
  • 1
  • 2
  • Is /usr/local/lib/libusb-1.0.dylib what you mean by "the libusb module"? What does `lipo -info /usr/local/lib/libusb-1.0.dylib` say? – Alex Martelli Jun 10 '10 at 01:06
  • Thanks for the command Alex! Apparently, when I was building libusb it was still building for x86_64. I went back to the libusb source and did the following: $ ./configure CC="gcc -m32" $ sudo make install Now, the output of the command you provided is: Non-fat file: /usr/local/lib/libusb-1.0.dylib is architecture: i386 Everything seems to be working now! Thanks for your help! – Jon Jun 10 '10 at 07:54

0 Answers0