[osgeo4w-dev] ImportError: OSGeo4W problems with Python/GDAL

Matt Wilkie matt.wilkie at gov.yk.ca
Tue May 8 13:21:32 EDT 2012


Hi Casper,

I think you'll need to start from as clean an environment as possible 
and add items to path until things break again.
For example, from a command shell (start > run > cmd.exe):

{{{
:: clear whole PATH
set path=

:: clear PYTHONPATH, PYTHONHOME
set pythonpath=
set pythonhome=

:: set basic o4w environment
cd /d c:\osgeo4w
set osgeo4w_root=%cd%
path=%osgeo4w_root%\bin
}}}

Now run python and import gdal.

If it works, from the same command shell run each bat in 
"osgeo4w\etc\ini" and test the python import again until something fails.

If it doesn't work, something is wrong with the current o4w package 
ecosystem and we'll try and dig it out.

If you get through all the ini bat's without error, then the problem 
lies somewhere in the host Windows environment. Likely culprits include 
things like other python directories or .dll's in PATH, PYTHONPATH or 
PYTHONHOME (not necessarily gdal dll's).

let us know how you make out,


matt wilkie
--------------------------------------------
Geomatics Analyst
Information Management and Technology
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
http://environmentyukon.gov.yk.ca/geomatics/
--------------------------------------------


On 07-May-2012 11:40 PM, Casper Børgesen (CABO) wrote:
>
> Hi!
>
> I am new to the GDAL world and I’m struggling with installing OSGeo4W 
> to a working state.
>
> I have downloaded and installed the latest edition OSGeo4W. The 
> install goes smoothly. I open the OSGeo4W Command shell and enter 
> Python. I have seen that I can test the basic Python/GDAL binding(?) 
> by entering
>
> >>> from osgeo import gdal
>
> This results in the following error:
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "C:\OSGeo4W\apps\Python27\lib\site-packages\osgeo\__init__.py", 
> line 21,
> in <module>
>     _gdal = swig_import_helper()
>   File "C:\OSGeo4W\apps\Python27\lib\site-packages\osgeo\__init__.py", 
> line 17,
> in swig_import_helper
>     _mod = imp.load_module('_gdal', fp, pathname, description)
> ImportError: DLL load failed: The operating system cannot run %1.
>
> I have read that this error might indicate that the installed 
> python/gdal libraries are incompatible, but I’m wondering if my 
> OSGeo4W installation is obstructed by another installation? The 
> following three lines are added to my path by the OSGeo4W Command shell:
>
> C:\OSGeo4W\bin
> C:\OSGeo4W\\apps\msys\bin
> C:\OSGeo4W\\apps\Python27\Scripts
>
> I have searched through my system looking for gdal*.dll, but I have 
> found none located within any of the folders in my PATH.
>
> What can I do to troubleshoot this problem?
>
> Regards, Casper
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/osgeo4w-dev/attachments/20120508/3bb6da98/attachment.html


More information about the osgeo4w-dev mailing list