Hexagon Geospatial
MENU

ERDAS IMAGINE

Discuss and share topics of interest using ERDAS IMAGINE the world’s leading geospatial data authoring system.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Occasional Contributor
Posts: 9
Registered: ‎02-22-2018

Configure Python to Load ERDAS IMAGINE 2018 Libraries

I am currently unable to reconfigure Python in order to use the ERDAS IMAGINE libraries. I had ERDAS IMAGINE already installed and then downloaded Python 3.4. I'm trying to follow the instructions below (provided in https://download.hexagongeospatial.com/en/downloads/imagine/spatial-modeler-2018-python-examples). 

 

Configuring Python to Load ERDAS IMAGINE Libraries

In order to write Python scripts referencing the ERDAS IMAGINE libraries ("import imagine", "from imagine import modeler"), you must add the ERDAS IMAGINE Python library path to your Python search path. Typically this is done by appending the library directory to the PYTHONPATH environmental variable. The ERDAS IMAGINE installation does this automatically if 64-bit Python 3.4 is installed first, or it can be done manually by running "Reconfigure Python" from the ERDAS IMAGINE workspace (File / Configuration / Reconfigure Python).

The ERDAS IMAGINE Python libraries are installed in:

  • $IMAGINE_HOME\usr\lib\x64URelease\python (64-bit)
  • $IMAGINE_HOME\usr\lib\Win32Release\python (32-bit)

Both the 32-bit and 64-bit libraries will load correctly as long as one path or the other is configured in PYTHONPATH.

 

I tried following the directions from https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows and created a new Environmental Variable to C:\ProgramData\ERDAS\ERDAS IMAGINE 2018\PluginManager\usr\lib\x64URelease\Python34, but I receive the following error when trying to follow the instructions in blue above: The current Python version is not supported by this version of Imagine (needs Python 3.4)!

 

 

Staff
Posts: 582
Registered: ‎02-02-2016

Re: Configure Python to Load ERDAS IMAGINE 2018 Libraries

Try setting your PYTHONPATH environmental variable using the location where you have ERDAS IMAGINE 2018 installed instead of the directory C:\ProgramData\ERDAS\ERDAS IMAGINE 2018\PluginManager\usr\lib\x64URelease\Python34.

 

For example, if you have ERDAS IMAGINE 2018 installed in the directory C:\Program Files\Hexagon\ERDAS IMAGINE 2018 this would be your $IMAGINE_HOME folder and you should set the PYTHONPATH environmental variable to C:\Program Files\Hexagon\ERDAS IMAGINE 2018\usr\lib\X64Release\python.

 

Regards,

 

Stephen Bent

Hexagon Geospatial Support

Occasional Contributor
Posts: 9
Registered: ‎02-22-2018

Re: Configure Python to Load ERDAS IMAGINE 2018 Libraries

[ Edited ]

Thank you Stephen for taking a look at this. I've finally gotten back around to this but am still having trouble. I installed Imagine 2018 (I previously had 2016) and was hoping the configuration would work since python 3.4 was already on the computer. However when I try to run

 

from imagine import modeler

 

in IDLE I get:

 

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from imagine import modeler
ImportError: No module named 'imagine'

 

I tried File > Configuration > Reconfigure Python > but still get the same error:

 

The current Python version is not supported by this version of Imagine (needs Python 3.4)!

 

However, I'm running Python 3.4.3, which I confirm with:

 

import sys; sys.version

 

I think I'm missing something from your instructions. I'm in user account controls > Advanced > Evironmental Variables. I interpret the first paragraph as set PYTHONPATH to $IMAGINE_HOME directory" (C:\ProgramData\ERDAS\ERDAS IMAGINE 2018) but then I interpret the second paragraph as set it to the python folder. I've tried setting it to both, but still can't run: from imagine import modeler.

 

Thanks for your help!

 

 

Frequent Contributor
Posts: 100
Registered: ‎04-03-2017

Re: Configure Python to Load ERDAS IMAGINE 2018 Libraries

I'm having the same trouble.

 

I follow the steps but Python can't find those modules.

I have Python 3.4.4.

Staff
Posts: 582
Registered: ‎02-02-2016

Re: Configure Python to Load ERDAS IMAGINE 2018 Libraries

kmeehan@usbr.gov,@JGEOG,

 

Are you sure that you have ERDAS IMAGINE 2018 installed under your C:\ProgramData folder? Or is it installed under the more common C:\Program Files directory?

 

You will need to determine the correct path to use for the PYTHONPATH environmental variable, then you need to combine your $IMAGINE_HOME directory with “usr\lib\X64URelease\python”. If you have ERDAS IMAGINE installed in “C:\Program Files\Hexagon\ERDAS IMAGINE 2018” then your PYTHONPATH variable will be  “C:\Program Files\Hexagon\ERDAS IMAGINE 2018\usr\lib\x64URelease\python”.

 

Kind regards,

 

Stephen Bent

Hexagon Geospatial Support

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.