[Gdal-dev] import _gdal issue

Simon Hope SimonH at geobiz.co.nz
Tue Oct 9 19:48:55 EDT 2007


Hey Chris,

Thanks for the email. I tried your suggestion;

>>> import _gdal
>>> print _gdal
<module '_gdal' from 'C:\Python24\Lib\site-packages\_gdal.pyd'>

Both ogr.py and _gdal.pyd are in the same location i.e.
'C:\Python24\Lib\site-packages'. 

Based upon the error -  the file  OGR.py
(FeatureServer\DataSource\OGR.py ) has no problem importing ogr.py
(C:\Python24\lib\site-packages\ogr.py), which is strange: the GDAL
ogr.py does not seem to be able to find the _gdal.pyd in the same
location?

I added the sys.path.append line to the featureserver cgi and nothing
changed.

You suggested that Apache may be using a different PYTHONPATH than
pythonwin. If this were the case would we not see an error at the point
that OGR.py tries to import ogr.py? Is there a mechanism to validate
what PYTHONPATH Apache is looking at?

Cheers

Simon

PS Chris Barker...just got your post and I'm glad to know I'm not going
mad

-----Original Message-----
From: Christopher Barker [mailto:Chris.Barker at noaa.gov] 
Sent: Wednesday, 10 October 2007 12:46 p.m.
To: Christopher Schmidt
Cc: gdal-dev at lists.maptools.org; Simon Hope
Subject: Re: [Gdal-dev] import _gdal issue

Christopher Schmidt wrote:
> On Wed, Oct 10, 2007 at 10:22:25AM +1300, Simon Hope wrote:
>>>>> import _gdal
>> And don't get any errors and have access to the members on that
module.
> 
> Pythonwin is probably using a different PYTHONPATH than apache is.
> Somewhere in that path _gdal is probably included. Others can probably
> comment more directly, but I would do something like:
> 
> import _gdal
> print _gdal
> 
> Which should give output like <module 'gdal' from
> 'C:\SomethingOrOther\gdal.dll'> or something similar.
> 
> Once you've done that, you should be able to add the following to the
> FeatureServer cgi:
> 
> sys.path.append("C:\SomethingOrOther")

It's worth a try, but something is odd. From that traceback:

   File "C:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\featureserver\FeatureServer\DataSource\OGR.p
y", line 2, in ?
     import ogr, osr
   File "C:\Python24\Lib\site-packages\ogr.py", line 33, in ?
     import _gdal

so it looks like ogr.py was found, but _gdal.pyd was not. They should 
both be in site_packages.

Take a look at C:\Python24\Lib\site-packages, and see what's there. 
there should be something like:


ogr.py
ogr.pyc
osr.py
osr.pyc
_gdal.pyd
gdal.py
gdal.pyc
gdalconst.py
gdalconst.pyc
gdalnumeric.py
gdalnumeric.pyc


in other words, _gdal.pyd should be in the same place as ogr.py, and 
therefor importable.

By the way in future next releases this should be a bit cleaned up -- 
with eveything in site_packages/osgeo/

Hopefully these problems will be easier to solve then.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev








More information about the Gdal-dev mailing list