5

l run into an problem "ImportError: DLL load failed: %1 is not a valid Win32 application" when l try to learn Building Spatial Models in Python on erdas document. For this , l m using Enthought Canopy (64-bit) on Pycharm.l would like to know how l can solve this problem? should l download Canopy 32 bit version but my pc is 64 bit, by the way.l have 64 bit version of ERDAS installed on my pc and l wonder whether Erdas 32 bit version Imagine module could solve this problem?

here is example code:

from exampleshelper import dataPath, outputPath
from imagine import modeler


m=modeler.Model()
ri = m.RasterInput(dataPath + "C:/Users/owrasa/PycharmProjects/den/data/lanier.img")
bandSelect = m.BandSelection(ri, "1:4")
sumBands = m.StackTotal(bandSelect)
ro = m.RasterOutput(sumBands, outputPath + "summing-image-layers.img")
m.Execute()

here is the whole error message:

C:\Users\owrasa\AppData\Local\Enthought\Canopy\User\Scripts\python.exe C:/Users/owrasa/PycharmProjects/den/layerstack.py
Using example data from C:/Users/owrasa/PycharmProjects/den\..\data\
 and saving results in C:/Users/owrasa/PycharmProjects/den\..\output\
Traceback (most recent call last):
  File "C:/Users/owrasa/PycharmProjects/den/layerstack.py", line 3, in <module>
    from imagine import modeler
  File "C:\Program Files\Intergraph\ERDAS IMAGINE 2014\usr\lib\Win32Release\python\imagine\__init__.py", line 19, in <module>
    import init
  File "C:\Program Files\Intergraph\ERDAS IMAGINE 2014\usr\lib\Win32Release\python\imagine\init\__init__.py", line 56, in <module>
    _initToolkit();
  File "C:\Program Files\Intergraph\ERDAS IMAGINE 2014\usr\lib\Win32Release\python\imagine\init\__init__.py", line 51, in _initToolkit
    import _init
ImportError: DLL load failed: %1 is not a valid Win32 application.

Process finished with exit code 1
ömer sarı
  • 639
  • 1
  • 10
  • 30
  • The term "Win32" (seen your traceback) is ambiguous (sometimes it is used in contrast to 64-bit, sometimes in contrast to older (16-bit) versions, in which case it includes both 32-bit and 64-bit). Because ERDAS is installed in "Program Files" rather than in "Program Files (X86)", it seems probable that you have the 64-bit of ERDAS installed, in which case the problem would not be solved by installing Canopy 32-bit. – Jonathan March Dec 11 '16 at 17:05
  • so l need 32 bit erdas python module to run the code without error ,right? – ömer sarı Dec 11 '16 at 18:40
  • Sorry, no, that's not what I meant. I will try to look at this again in the next few days. You might want to tag erdas on this question too. – Jonathan March Dec 12 '16 at 00:31
  • if you're doing 64bit, everything need to by 64bit, is your python version x64 ? It's full x64 or full x86. don't mix it – PyNico Dec 14 '16 at 09:24
  • my all software are 64 bit but in Erdas 64 bit version , Win32release folder only include imagine modül and there is no 64 bit imagine version in it. is there any way to convert a module in 64 bit? – ömer sarı Dec 15 '16 at 16:21
  • 1) As I mentioned before, don't assume that the Win32Release folder is 32-bit software. – Jonathan March Dec 17 '16 at 00:42
  • 2) No, there's no way for a user to convert a program between 32 and 64 bit – Jonathan March Dec 17 '16 at 00:43
  • You can perhaps use Process Explorer to see what DLL the system is attempting to load with no success. It's a lengthy task (ProcExp outputs a *lot* of information and you will have to filter out everything that is not related to your app before even starting), but it should tell you which DLL(s) is/are missing, which in turn should tell you what you need to install or reconfigure. – LSerni Dec 19 '16 at 07:47

1 Answers1

0

You're trying to load a 32 bits DLL into a 64 bits application, that's what the error is about. The only way to "convert" your module to 32 bit is recompiling from source

yorodm
  • 4,359
  • 24
  • 32
  • Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32 , when l check the version.so my python is 32 bit ,still this error message is normal?? – ömer sarı Apr 04 '17 at 12:44