moliware/pyunitex

libunitex.so permissions

Closed this issue · 2 comments

Hi moliware,
when I copy the libunitex.so in either /usr/lib or /usr/local/lib I got the following error:

>>> import pyunitex
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/pyunitex/__init__.py", line 2, in <module>
    from pyunitex import Unitex
  File "/Library/Python/2.6/site-packages/pyunitex/pyunitex.py", line 11, in <module>
    unitex = ctypes.cdll.LoadLibrary(unitex_lib)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 423, in LoadLibrary
    return self._dlltype(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 345, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libunitex.so, 6): no suitable image found.  Did find:
    /usr/lib/libunitex.so: mach-o, but wrong architecture

I guess is a permissions issue since when I run the script with as root everything works properly. I tried changing the owner of the file (chwon) to root:wheel, but it didn't help.

My laptop is a Macbook Pro, Snow Leopard. I'm using Python 2.6.1.
Any thoughts?

Hi fertapric,

Make sure that libunitex.so is compiled as 64/32bit and you are using 64/32bit python.
For checking first thing you can execute:
lipo -info /usr/local/lib/libunitex.so

For checking python:


> > > sys.maxint
> > > 9223372036854775807
> > > 
> > > ```
> > > In this case it's a 64 bit python
> > > ```

If libunitex and python have different architectures you can recompile libunitex or force python to be 32/64 bit (http://stackoverflow.com/questions/2088569/how-do-i-force-python-to-be-32-bit-on-snow-leopard-and-other-32-bit-64-bit-questi/3059113)

Yeah, it worked. Good googling ;)
Here is the trick:

export VERSIONER_PYTHON_PREFER_64_BIT=yes
export VERSIONER_PYTHON_PREFER_32_BIT=no

I would update the wiki with this one.