[gdal-dev] Python documentation help

Lucena, Ivan ivan.lucena at pmldnet.com
Wed Dec 5 15:00:34 EST 2007


Howard, Chris,

Howard Butler wrote:
> 
> On Dec 5, 2007, at 11:55 AM, Christopher Barker wrote:
> 
>> Lucena, Ivan wrote:
>>> Note: I tried the old import and the new one just to make sure.
>>> >>> import gdal
>>> Traceback (most recent call last):
>>>  File "<interactive input>", line 1, in ?
>>>  File "C:\Progra~1\Python24\Lib\site-packages\gdal.py", line 6, in ?
>>>    import _gdal
>>> ImportError: No module named _gdal
>>
>> umm, isn't that a bug? I thought we were keeping it backward 
>> compatible (with a deprecation warning) for this release.
> 
> 
> Ivan,
> 
> I suspect that C:\Progra~1\Python24\Lib\site-packages\gdal.py is and 
> old-generation gdal.py in the way.  If you open it up and it is more 
> than 10 lines of code, this is probably the case.  Did you install the 
> old-generation stuff *after* installing the next-generation?

No, I didn't. I am sure that I have done that a long time *before* but 
not after. And yes, the gdal.py has more than 10 lines of code. A lot 
more. So let me start over and see what happens:

On "Add or Remove Programs" I remove "Python 2.4 GDAL-1.5.0.a.dev":

---------------------------
Uninstall Finished!
---------------------------
42 files and 1 directories removed
---------------------------
OK
---------------------------

Now python doesn't have GDAL anymore:

 >>> import gdal
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
ImportError: No module named gdal
 >>>

There is no osgeo folder or any gdal*.* or ogr*.* file on site-packages.

So I run GDAL-1.5.0.a.dev.win32-py2.4.exe again and just after that I try:

 >>> import gdal
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
   File "C:\Progra~1\Python24\Lib\site-packages\gdal.py", line 6, in ?
     import _gdal
ImportError: No module named _gdal
 >>>

I guess that what you would expect is that \Lib\site-packages\gdal.py 
would be smaller, just a wrapper to call the osgeo\gdal.py.

But again *before* running the GDAL Python Installer I have no gdal.py 
and just *after* running it I have a big one and I got an error when 
using "import gdal" but I have no problem using "from osgeo import gdal".

I am going to try later in another computer with a fresh Python 
installation to see what happen and I will not going to run SWIG this 
time, OK?

Anyway, I think we should add a Windows section on that wiki page. What 
do you think?

Best regards,

Ivan


More information about the gdal-dev mailing list