Install GDAL and GRASS on python Web App

Dhananjay Agarwal 0 Reputation points
2025-03-13T00:59:08.62+00:00

I have developed a python script that uses GDAL and GRASS and runs fine on my local Macbook Pro. I need to make the python scripts work on the Azure Web App. For this I need to install GDAL and GRASS on the web app server. On my local machine, I am using GDAL version 3.10.2 and Grass version 8.4.0. How can I install these so my script works fine on the web-app server?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,452 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Prabhavathi Manchala 80 Reputation points Microsoft External Staff
    2025-03-13T14:49:45.8433333+00:00

    Hi Dhananjay Agarwal,

    Thank you for confirming that you are not using a Docker Container for your web application.

    1.You can include GDAL directly in your requirements.txt file or install it manually using pip, given that native system installation is restricted, installing via pip will eliminate the need for sudo access.

    GDAL==3.10.2
    

    run by using below command.

    pip install -r requirements.txt
    

    you can install it directly as below.

    pip install GDAL==3.10.2
    

    After installation, please confirm the setup by verifying the GDAL version within your Python code.

    import osgeo
    print(osgeo.__version__)
    

    If the installation was successful, it should display version 3.10.2.

    1. Please install GRASS GIS Python bindings via grass-session. add the following to your requirements.txt file.
    grass-session
    

    run by using below command.

    pip install -r requirements.txt
    

    If you need to install GRASS GIS and other dependencies, consider using a custom startup script in the Azure Web App's configuration settings.

    Please create a custom startup.sh script as below.

    #!/bin/bash
    apt-get update
    apt-get install -y gdal-bin grass
    pip install -r /home/site/wwwroot/requirements.txt
    

    You can configure the application to execute the startup.sh script in your app configuration settings.

    0 comments No comments

  2. Dhananjay Agarwal 0 Reputation points
    2025-03-13T15:46:18.01+00:00

    Please note that I am not using Docker container. I ran pip install GDAL==3.10.2 and I got the following error.

    root@94276ae1d814:/home/site/wwwroot# pip install GDAL==3.10.2

    Collecting GDAL==3.10.2

    Downloading gdal-3.10.2.tar.gz (838 kB)

     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 838.1/838.1 kB 41.3 MB/s eta 0:00:00
    

    Installing build dependencies ... done

    Getting requirements to build wheel ... error

    error: subprocess-exited-with-error

    × Getting requirements to build wheel did not run successfully.

    │ exit code: 1

    ╰─> [88 lines of output]

      /tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:81: SetuptoolsWarning: `extras_require` overwritten in `pyproject.toml` (optional-dependencies)
    
        corresp(dist, value, root_dir)
    
      Using numpy 2.2.3
    
      running egg_info
    
      writing gdal-utils/GDAL.egg-info/PKG-INFO
    
      writing dependency_links to gdal-utils/GDAL.egg-info/dependency_links.txt
    
      writing entry points to gdal-utils/GDAL.egg-info/entry_points.txt
    
      writing requirements to gdal-utils/GDAL.egg-info/requires.txt
    
      writing top-level names to gdal-utils/GDAL.egg-info/top_level.txt
    
      Traceback (most recent call last):
    
        File "<string>", line 91, in fetch_config
    
        File "/opt/python/3.10.16/lib/python3.10/subprocess.py", line 971, in __init__
    
          self._execute_child(args, executable, preexec_fn, close_fds,
    
        File "/opt/python/3.10.16/lib/python3.10/subprocess.py", line 1863, in _execute_child
    
          raise child_exception_type(errno_num, err_msg, err_filename)
    
      FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
    
      
    
      During handling of the above exception, another exception occurred:
    
      
    
      Traceback (most recent call last):
    
        File "<string>", line 231, in get_gdal_config
    
        File "<string>", line 94, in fetch_config
    
      __main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
    
      
    
      During handling of the above exception, another exception occurred:
    
      
    
      Traceback (most recent call last):
    
        File "/opt/python/3.10.16/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
    
          main()
    
        File "/opt/python/3.10.16/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
    
          json_out["return_val"] = hook(**hook_input["kwargs"])
    
        File "/opt/python/3.10.16/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
    
          return hook(config_settings)
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
    
          return self._get_build_requires(config_settings, requirements=[])
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
    
          self.run_setup()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
    
          exec(code, locals())
    
        File "<string>", line 437, in <module>
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup
    
          return distutils.core.setup(**attrs)
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 186, in setup
    
          return run_commands(dist)
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
    
          dist.run_commands()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
    
          self.run_command(cmd)
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 999, in run_command
    
          super().run_command(command)
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
    
          cmd_obj.run()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 312, in run
    
          self.find_sources()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 320, in find_sources
    
          mm.run()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 543, in run
    
          self.add_defaults()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 581, in add_defaults
    
          sdist.add_defaults(self)
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/command/sdist.py", line 109, in add_defaults
    
          super().add_defaults()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 245, in add_defaults
    
          self._add_defaults_ext()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 329, in _add_defaults_ext
    
          build_ext = self.get_finalized_command('build_ext')
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 334, in get_finalized_command
    
          cmd_obj.ensure_finalized()
    
        File "/tmp/pip-build-env-9ngbd8f1/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 135, in ensure_finalized
    
          self.finalize_options()
    
        File "<string>", line 315, in finalize_options
    
        File "<string>", line 237, in get_gdal_config
    
      __main__.gdal_config_error: Traceback (most recent call last):
    
        File "<string>", line 91, in fetch_config
    
        File "/opt/python/3.10.16/lib/python3.10/subprocess.py", line 971, in __init__
    
          self._execute_child(args, executable, preexec_fn, close_fds,
    
        File "/opt/python/3.10.16/lib/python3.10/subprocess.py", line 1863, in _execute_child
    
          raise child_exception_type(errno_num, err_msg, err_filename)
    
      FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
    
      
    
      During handling of the above exception, another exception occurred:
    
      
    
      Traceback (most recent call last):
    
        File "<string>", line 231, in get_gdal_config
    
        File "<string>", line 94, in fetch_config
    
      gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
    
      
    
      Could not find gdal-config. Make sure you have installed the GDAL native library and development headers.
    
      [end of output]
    

    note: This error originates from a subprocess, and is likely not a problem with pip.

    error: subprocess-exited-with-error

    × Getting requirements to build wheel did not run successfully.

    │ exit code: 1

    ╰─> See above for output.

    note: This error originates from a subprocess, and is likely not a problem with pip.

    root@94276ae1d814:/home/site/wwwroot#

    Please assist. I am stuck at GDAL so not even trying GRASS GIS yet.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.