[GRASS-dev] python grass problems on OSX (Incompatible library version for module)

Hi All,

i'm tring to utilize a python function iside the grass environment,
but i gett errors about :

"Incompatible library version for module"

outside a running GRASS, it works from python. From python started inside a GRASS shell, it doesn't work.

the function i'm using is prety simple :

###
import os
import subprocess

def OssimImg2rr(img1):
     os.environ['DYLD_FRAMEWORK_PATH'] = '/var/tmp/XcodeBuilds/Release'
     os.environ['OSSIM_PREFS_FILE'] = '/Users/sasha/ossim_preferences'
     output = subprocess.Popen(['/var/tmp/XcodeBuilds/Release/img2rr' ,str(img1)],stdout=subprocess.PIPE).communicate()[0]
###

as i described first,
these code works fine in a standard python shall, but if i try to run it from python iside grass shell, i get the error about incompatible library version.

note :
the same code works fine on linux, without erors.

i tried to buuild both grass and ossim using the same gdal.framework as dependencies,
i tried to run (in osx) the same code in grass65 (thinking about a gdal-grass version problem) but nothing, the error pesists

i don't think is a gdal issue beacouse img2rr do not use gdal, but it is a simple unix command wrapper.

maybe it is a problem related to

"
import os
import subprocess
"
Sounds like GRASS is corrupting the python environment somehow.

have youy any clue ?

thanks for any help!

regards,

Massimo Di Stefano
massimodisasha@yahoo.it

epifanio on irc.freenode.net /join gfoss

Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com

massimo di stefano wrote:

i'm tring to utilize a python function iside the grass environment,
but i gett errors about :

"Incompatible library version for module"

If "make clean" and rebuilding doesn't fix it, then it sounds like you
have more than one version of GRASS on your system, and it's picking
up the wrong libraries.

outside a running GRASS, it works from python. From python started
inside a GRASS shell, it doesn't work.

That sounds like multiple versions.

the function i'm using is prety simple :

###
import os
import subprocess

def OssimImg2rr(img1):
     os.environ['DYLD_FRAMEWORK_PATH'] = '/var/tmp/XcodeBuilds/Release'
     os.environ['OSSIM_PREFS_FILE'] = '/Users/sasha/ossim_preferences'
     output = subprocess.Popen(['/var/tmp/XcodeBuilds/Release/img2rr' ,str(img1)],stdout=subprocess.PIPE).communicate()[0]

Leave os.environ alone; create a new environment dictionary and pass
that to subprocess.Popen(), e.g.:

  myenv = os.environ.copy()
  myenv['DYLD_FRAMEWORK_PATH'] = '/var/tmp/XcodeBuilds/Release'
  myenv['OSSIM_PREFS_FILE'] = '/Users/sasha/ossim_preferences'
  output = subprocess.Popen(..., env = myenv).communicate()[0]

This isn't related to this specific problem, though, just general
Python coding advice.

--
Glynn Clements <glynn@gclements.plus.com>

Hi Glynn, All,

Il giorno 11/mag/09, alle ore 03:32, Glynn Clements ha scritto:

massimo di stefano wrote:

i'm tring to utilize a python function iside the grass environment,
but i gett errors about :

"Incompatible library version for module"

If "make clean" and rebuilding doesn't fix it, then it sounds like you
have more than one version of GRASS on your system, and it's picking
up the wrong libraries.

Yes it is, i tried make clean && make distclean,
i also tried on a fresh svn download.
I've installed on my system different grass versions :

grass64 (binary verion)
grass65 , grass70 (from svn)

outside a running GRASS, it works from python. From python started
inside a GRASS shell, it doesn't work.

That sounds like multiple versions.

How to avoid this problem?
has my system hardcoded some where the existence oh other grss version? can i masherate/eliminate something?

the function i'm using is prety simple :

###
import os
import subprocess

def OssimImg2rr(img1):
    os.environ['DYLD_FRAMEWORK_PATH'] = '/var/tmp/XcodeBuilds/Release'
    os.environ['OSSIM_PREFS_FILE'] = '/Users/sasha/ossim_preferences'
    output = subprocess.Popen(['/var/tmp/XcodeBuilds/Release/img2rr' ,str(img1)],stdout=subprocess.PIPE).communicate()[0]

Leave os.environ alone; create a new environment dictionary and pass
that to subprocess.Popen(), e.g.:

  myenv = os.environ.copy()
  myenv['DYLD_FRAMEWORK_PATH'] = '/var/tmp/XcodeBuilds/Release'
  myenv['OSSIM_PREFS_FILE'] = '/Users/sasha/ossim_preferences'
  output = subprocess.Popen(..., env = myenv).communicate()[0]

This isn't related to this specific problem, though, just general
Python coding advice.

Thanks! i'm self.teached so advice like these ere for me a great help

i hope i modified it well :

def OssimImg2rr(img1):
     myenv = os.environ.copy()
     myenv['DYLD_FRAMEWORK_PATH'] = '/var/tmp/XcodeBuilds/Release'
     myenv['OSSIM_PREFS_FILE'] = '/Users/sasha/ossim_preferences'
     output = subprocess.Popen(['/var/tmp/XcodeBuilds/Release/img2rr' ,str(img1)], stdout=subprocess.PIPE, env = myenv).communicate()[0]

Massimo Di Stefano
massimodisasha@yahoo.it

epifanio on irc.freenode.net /join gfoss

Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com

On May 11, 2009, at 1:02 AM, massimo di stefano wrote:

outside a running GRASS, it works from python. From python started
inside a GRASS shell, it doesn't work.

That sounds like multiple versions.

How to avoid this problem?
has my system hardcoded some where the existence oh other grss version? can i masherate/eliminate something?

Build them as Mac applications, and they won't interfere with each other. See the source macosx readme. Though even as a unix build they shouldn't, since each is in a self-contained version-named folder.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"The beast is actively interested only in now, and, as it is always now and always shall be, there is an eternity of time for the accomplishment of objects."

- the wisdom of Tarzan

massimo di stefano wrote:

>> i'm tring to utilize a python function iside the grass environment,
>> but i gett errors about :
>>
>> "Incompatible library version for module"
>
> If "make clean" and rebuilding doesn't fix it, then it sounds like you
> have more than one version of GRASS on your system, and it's picking
> up the wrong libraries.
>

Yes it is, i tried make clean && make distclean,
i also tried on a fresh svn download.
I've installed on my system different grass versions :

grass64 (binary verion)
grass65 , grass70 (from svn)

>> outside a running GRASS, it works from python. From python started
>> inside a GRASS shell, it doesn't work.
>
> That sounds like multiple versions.

How to avoid this problem?

Don't have more than one version.

If you must have more than one version, ensure that no part of GRASS
or any library which links against GRASS (e.g. GDAL) is installed
outside of the GISBASE directory (i.e. not in /usr or in /usr/local
or, on a Mac, in /System).

If you want more than one version, and you want one of those versions
to be installed outside of the GISBASE directory, and you want to
build programs which work with the other version, then you need to
understand the compilation, linking and loading processes in some
detail.

Finally, note that any program which uses GRASS libraries will only
ever work with the specific version for which it was built. You can't
create an executable which will work with more than version.

--
Glynn Clements <glynn@gclements.plus.com>