Arpit
Arpit

Reputation: 11

Faild to import gdal/ogr modules in python2 environment for Anuga model

I installed anuga from https://github.com/GeoscienceAustralia/anuga_core. Aunga work on python2 instead of python3. After installation of anuga, i run the runtests.py in terminal window to testify that all required environment is created.

Python version 2.7.18 and gdal 3.0.4 were already installed

After running the test file, i am getting the following error:

ImportError: Failed to import gdal/ogr modules --perhaps gdal python interface is not installed.

Traceback (most recent call last): File "/home/satyukt/Projects/anuga/anuga_core/build/testenv/lib/python2.7/site-packages/anuga/file_conversion/tests/test_csv2sts.py", line 92, in test_run_via_commandline self._check_generated_sts() File "/home/satyukt/Projects/anuga/anuga_core/build/testenv/lib/python2.7/site-packages/anuga/file_conversion/tests/test_csv2sts.py", line 97, in _check_generated_sts sts = NetCDFFile(sts_out,'r') File "/home/satyukt/Projects/anuga/anuga_core/build/testenv/lib/python2.7/site-packages/anuga/file/netcdf.py", line 62, in NetCDFFile return Dataset(file_name, netcdf_mode, format='NETCDF3_64BIT') File "netCDF4/_netCDF4.pyx", line 2123, in netCDF4._netCDF4.Dataset.init File "netCDF4/_netCDF4.pyx", line 1743, in netCDF4._netCDF4._ensure_nc_success IOError: [Errno 2] No such file or directory: 'sts_out.sts'

====================================================================== ERROR: test_Make_Geotif (test_plot_utils.Test_plot_utils)

Traceback (most recent call last): File "/home/satyukt/Projects/anuga/anuga_core/build/testenv/lib/python2.7/site-packages/anuga/utilities/tests/test_plot_utils.py", line 407, in test_Make_Geotif EPSG_CODE=32756, output_dir='.', CellSize=myCellSize) File "/home/satyukt/Projects/anuga/anuga_core/build/testenv/lib/python2.7/site-packages/anuga/utilities/plot_utils.py", line 1004, in Make_Geotif raise ImportError, msg ImportError: Failed to import gdal/ogr modules --perhaps gdal python interface is not installed.

====================================================================== ERROR: test_Make_Geotif_with_knn (test_plot_utils.Test_plot_utils)

Traceback (most recent call last): File "/home/satyukt/Projects/anuga/anuga_core/build/testenv/lib/python2.7/site-packages/anuga/utilities/tests/test_plot_utils.py", line 440, in test_Make_Geotif_with_knn k_nearest_neighbours=4) File "/home/satyukt/Projects/anuga/anuga_core/build/testenv/lib/python2.7/site-packages/anuga/utilities/plot_utils.py", line 1004, in Make_Geotif raise ImportError, msg ImportError: Failed to import gdal/ogr modules --perhaps gdal python interface is not installed.

Ran 1252 tests in 94.942s

FAILED (errors=14)

How can i import gdal/ogr modules in python2 environment?

Upvotes: 1

Views: 114

Answers (1)

Jayashri Pawar
Jayashri Pawar

Reputation: 1

Try to upgrade your GDAL version. The default one is 2.2 but now it is not supported by ANUGA python-2. Previously GDAL 3.0.4 was supporting ANUGA python-2 but the GDAL-3.0.4 now supporting only python3.x. Hence the supporting version now is: GDAL-2.4.2

You can install it in your conda env by using the following command:

conda install -c conda-forge gdal=2.4.2

Upvotes: 0

Related Questions