Error setting up InVEST for batch running

Hi,

I've been trying to set up a Python script for batch running using this tutorial: http://invest.readthedocs.io/en/latest/scripting.html. I got up to step 4 of "Creating Sample Python Scripts"-- opening up a Windows Powershell and running the script-- when I ran into an error that said a necessary module was missing ("ImportError: no module named osgeo"; "FullyQualifiedErrorID: NativeCommandError"). (A full screenshot of the error screen is attached to this post.)

         I don't have a lot of experience with Python, and I'm not sure what to do next. If anyone knows or has any tips on how to fix this, it would be greatly appreciated.

Other important information:
I am using Python version 3.7.7, and InVEST python build version 3.4.4. (win32.exe version). 

Thank you!
-Andie

908 x 600 - 91K

Comments

  • RichRich Administrator, NatCap Staff
    Hi Andie, the error is related to GDAL not being installed, but InVEST is only Python 2.7 compatible at the moment. We're actively working on that, but there may not be much you can do at the moment unless you're interested in installing a 2.7 Python environment.
  • jdouglassjdouglass Administrator, NatCap Staff
    Hi Andie,  Based on the exception, it looks like Python 2.7 might indeed be the active python version.  If so, it looks like the osgeo ("GDAL") package is missing.  Could you download one of the GDAL 2 packages from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and use pip to install that file?  The file to download will be either the one labeled 'cp27-cp27m-win32' or 'cp27-cp27m-win_amd64' depending on if your python installation is 32-bit of 64-bit.

    Hopefully that'll fix the import!
  • areidyareidy Member
    Thank you both! I switched to Python 2.7 and then installed GDAL-2.2.4-cp27-cp27m-win32.whl, and that fixed the missing module problem. 

    Andie

  • areidyareidy Member
    Working on this same tutorial, I ran into a different problem when trying to run the script in Powershell. I've tried all kinds of things to fix it, but I still keep getting the same error every time. Here's the full traceback:

    PS C:\Users\andie> C:\Python27\ArcGIS10.5\python.exe C:\Users\andie\Documents\NDR_python\python_script.py
    C:\Python27\ArcGIS10.5\python.exe : Traceback (most recent call last):
    At line:1 char:1
    + C:\Python27\ArcGIS10.5\python.exe C:\Users\andie\Documents\NDR_python ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
     
      File "C:\Users\andie\Documents\NDR_python\python_script.py", line 6, in <module>
        import natcap.invest.ndr.ndr
      File "C:\Python27\ArcGIS10.5\lib\site-packages\natcap\invest\__init__.py", line 8, in <module>
        import pygeoprocessing
      File "C:\Python27\ArcGIS10.5\lib\site-packages\pygeoprocessing\__init__.py", line 13, in <module>
        from . import geoprocessing
      File "C:\Python27\ArcGIS10.5\lib\site-packages\pygeoprocessing\geoprocessing.py", line 25, in <module>
        import scipy.interpolate
      File "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\interpolate\__init__.py", line 158, in <module>
        from .interpolate import *
      File "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\interpolate\interpolate.py", line 11, in <module>
        import scipy.linalg
      File "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\linalg\__init__.py", line 174, in <module>
        from .misc import *
      File "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
        from .blas import get_blas_funcs
      File "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\linalg\blas.py", line 155, in <module>
        from scipy.linalg import _fblas
    ImportError: DLL load failed: The specified module could not be found.

    I've also attached a screenshot of a list of packages that I have (using list function on Powershell). I'm using Python version 2.7.15 and the most recent build of InVEST Python. If anyone could help me with this I would greatly appreciate it.

    Andie
    1366 x 768 - 135K
  • jdouglassjdouglass Administrator, NatCap Staff
    Hi Andie, interesting error!  Could you try installing one of the scipy packages from https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy and see if that resolves the import issue?
Sign In or Register to comment.