>On Wed, Sep 8, 2010 at 2:32 AM,  <[email protected]> wrote:
>> Dear Shapely-Developers,
>>
>> First: thank you for Shapely!
>> I have to install Shapely on a cluster (scientific linux), where i don't
have root privilegs. Python, as well as libgeos_c are installed (from
source) under $HOME/local/lib and $HOME/local/bin. The first is in
$LD_LIBRARY_PATH and the latter in $PATH. Unfortunatly ctypes.find_library
seems to fail under these circumstances. Can you fix geos.py to fall back to
the any *nix variant, for loading libgeos_c, if find_library does not find
the library?
>>
>> A possible solution (working for me) could be changing line 28-32 in
geos.py to (inspired by your code line 83-92):
>>
>> if sys.platform == 'linux2':
>>    lib = find_library('geos_c')
>>    if lib is None:
>>        try:
>>            _lgeos = CDLL('libgeos_c.so.1')
>>        except (OSError, ImportError):
>>            _lgeos = CDLL('libgeos_c.so')
>>        except:
>>            raise
>>    else:
>>        _lgeos = CDLL(lib)
>>    free = CDLL(find_library('c')).free
>>    free.argtypes = [c_void_p]
>>    free.restype = None
>>
>>
>> Thank you,
>>
>> Philipp
>
>Hi Philipp,
>
>You are very welcome! I'm glad you like it.
>
>I won't rule out the change you suggested, but first I'd like to make
>sure that we can't solve this by sorting your library path. I am
>routinely testing and deploying Shapely using zc.buildout and
>modifying LD_LIBRARY_PATH so that Shapely (in a virtualenv) can find a
>specific, local libgeos_c.so (also built from source). Without any
>root privileges or system-wide installs. Can you check that
>$HOME/local/lib and $HOME/local/bin are at the head of LD_LIBRARY_PATH
>and PATH?
>
>Cheers,
>
>--
>Sean
>
>
Dear Sean,
thank you for your prompt answer.
I checked the paths, but since I'm not a Linux-pro I attach some output
(variables, errormsg's, tests). However, it may always happen, for different
resaons, that find_library fails (e.g. geos missing). Some kind of error
handling with a clear error message (like "libgeos_c not found") might be
nice anyway. 
The system I am using is a commercial cluster system with scientific linux
5.5. 

So here's my environment:

[gh1...@skylla1 ~]$ echo $PATH
/home/gh1961/local/lib:/home/gh1961/local/bin:/cm/shared/apps/gcc/4.3.4/bin:
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/cm/shared/ap
ps/mvapich2/gcc/64/1.2/bin:/cm/shared/apps/mvapich2/gcc/64/1.2/sbin:/home/gh
1961/bin
[gh1...@skylla1 ~]$ echo $LD_LIBRARY_PATH
/home/gh1961/local/bin:/cm/shared/apps/gcc/4.3.4/lib:/cm/shared/apps/gcc/4.3
.4/lib64:/cm/shared/apps/mvapich2/gcc/64/1.2/lib
[gh1...@skylla1 ~]$

My error message
****************************************************************
>>> from shapely.geometry import Point
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/home/gh1961/local/lib/python2.6/site-packages/Shapely-1.2.3-py2.6.egg/shap
ely/geometry/__init__.py", line 4, in <module>
    from geo import shape, asShape, mapping
  File
"/home/gh1961/local/lib/python2.6/site-packages/Shapely-1.2.3-py2.6.egg/shap
ely/geometry/geo.py", line 5, in <module>
    from point import Point, asPoint
  File
"/home/gh1961/local/lib/python2.6/site-packages/Shapely-1.2.3-py2.6.egg/shap
ely/geometry/point.py", line 7, in <module>
    from shapely.geos import lgeos, DimensionError
  File
"/home/gh1961/local/lib/python2.6/site-packages/Shapely-1.2.3-py2.6.egg/shap
ely/geos.py", line 103, in <module>
    geos_capi_version = geos_c_version = _geos_c_version()
  File
"/home/gh1961/local/lib/python2.6/site-packages/Shapely-1.2.3-py2.6.egg/shap
ely/geos.py", line 98, in _geos_c_version
    func = _lgeos.GEOSversion
  File "/home/gh1961/local/lib/python2.6/ctypes/__init__.py", line 366, in
__getattr__
    func = self.__getitem__(name)
  File "/home/gh1961/local/lib/python2.6/ctypes/__init__.py", line 371, in
__getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: GEOSversion

****************************************************************************
*************
Trying find_library:
>>> from ctypes.util import find_library
>>> print find_library('c')
libc.so.6
>>> print find_library('geos_c')
None
>>> from ctypes import CDLL
>>> CDLL('libgeos_c.so')
<CDLL 'libgeos_c.so', handle 84e1c0 at 2aaaaabb0fd0>

Cheers,

Philipp

_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to