I'm new in QGIS and I'm trying to export my QGIS project to MapServer, using RT MapServer extension, because there is not any other extension in my version of QGIS (QGIS 2.18 on Windows). After installing the extension, when i try to export, there is this error even though I already installed Python mapscript on my cmd windows.

Any idea how to export a QGIS project to MapServer its for my project? I tried everything but nothing seems to work .

Traceback (most recent call last):
              File "C:/Users/NIHAD/.qgis2/python/plugins\rt_mapserver_exporter\plugin.py", line 65, in run
                from .mapfileexportdlg import MapfileExportDlg
              File "C:/PROGRA~1/QGIS2~1.18/apps/qgis-ltr/./python\qgis\utils.py", line 607, in _import
                mod = _builtin_import(name, globals, locals, fromlist, level)
              File "C:/Users/NIHAD/.qgis2/python/plugins\rt_mapserver_exporter\mapfileexportdlg.py", line 31, in <module>
                import MapfileExporter
              File "C:/PROGRA~1/QGIS2~1.18/apps/qgis-ltr/./python\qgis\utils.py", line 607, in _import
                mod = _builtin_import(name, globals, locals, fromlist, level)
              File "C:/Users/NIHAD/.qgis2/python/plugins\rt_mapserver_exporter\MapfileExporter.py", line 9, in <module>
                from utils import *
              File "C:/PROGRA~1/QGIS2~1.18/apps/qgis-ltr/./python\qgis\utils.py", line 607, in _import
                mod = _builtin_import(name, globals, locals, fromlist, level)
              File "C:/Users/NIHAD/.qgis2/python/plugins\rt_mapserver_exporter\utils.py", line 1, in <module>
                import mapscript
              File "C:/PROGRA~1/QGIS2~1.18/apps/qgis-ltr/./python\qgis\utils.py", line 607, in _import
                mod = _builtin_import(name, globals, locals, fromlist, level)
            ImportError: No module named mapscript

1 Answer 1


Summary: It's quite a mess. The RT MapServer plugin is not well maintained (last commit 2015 e.g https://github.com/faunalia/rt_mapserver_exporter) and it requires Python Mapscript.

So the plugin should be working for Mapserver 6.4 series, maybe 6.6 when looking at releases date. The problem is that Mapscript version should match the Mapserver version and should be for Python 2.7 (QGIS 2.18 is Python 2.7 based). You need to install Python mapscript using the Python from your QGIS installation e.g C:/PROGRA~1/QGIS2~1.18/bin/python.exe -m pip install mapscript.

The above will not work if you do not install Mapserver like mentioned at https://pypi.org/project/mapscript/#installation-on-windows

The problem: you will need to install an upper version of Mapserver that match the mapscript version e.g https://pypi.org/project/mapscript/#history as there are no available mapscript version matching the 6.4/6.6 requirements from the RT Mapserver plugin.

Conclusion: after you struggle to install Mapserver with Python using an upper version, hope that compatibility between the QGIS RT MapServer plugin and Mapserver version and associated Python mapscript will work more or less well when you will export.

Old recipe: Python Mapscript not available anymore in OSGEO4W after looking again (e.g in obsolete directory https://download.osgeo.org/osgeo4w/x86_64/release/_obsolete/mapserver/mapserver/). Sorry for misleading you.

You need to install mapscript-python, the Python bindings to Mapserver as they are not included in QGIS. For this, run the OSGEO4W installer behind the scene of your QGIS installation, located at C:/PROGRA~1/QGIS2~1.18/OSGeo4W.bat. Double click on the file. It will display a GUI. In "Advanced install", tick the box mapscript-python. Then, you will stop getting error "No module named mapscript" when using "RT MapServer" plugin.

  • thank you for your help, but i when i run the OSGEO4W installer i can't find the mapscript-python did i not download it correctly ?
    – jzreal
    Jun 14, 2021 at 16:47
  • Made an edit to my answer.
    – ThomasG77
    Jun 14, 2021 at 21:03
  • Made another edit after investigating and not announcing only good news...
    – ThomasG77
    Jun 14, 2021 at 21:48
  • thank you for your answer i appreciate that
    – jzreal
    Jun 14, 2021 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.