<div dir="ltr"><div dir="ltr"><div dir="ltr">I'm trying to write a PyQGIS standalone script which utilizes MapScript for certain tasks. In a first attempt, I basically did this:</div><div dir="ltr"><br></div><div>- I installed MapScript globally with pip and using the Python 3.9.5 interpreter which ships with QGIS 3.22.6 (also includes wheel)</div><div>- Created a venv with --system-site-packages</div><div>- Downloaded the appropriate Windows binary build of MapServer from GISInternals (release-1928-x64-gdal-3-4-mapserver-7-6) and extracted into C:\MapServer\</div><div>- Set the MAPSERVER_DLL_PATH to C:\MapServer\bin</div><div dir="ltr"><br></div><div>However, whenever I try to load MapScript, it yields the following:</div><div><br></div><div><div>Traceback (most recent call last):</div><div>  File "<string>", line 1, in <module></div><div>  File "C:\QGIS\apps\Python39\lib\site-packages\mapscript\__init__.py", line 2, in <module></div><div>    from .mapscript import *</div><div>  File "C:\QGIS\apps\Python39\lib\site-packages\mapscript\mapscript.py", line 13, in <module></div><div>    from . import _mapscript</div><div>ImportError: DLL load failed while importing _mapscript: The specified module could not be found.</div></div><div><br></div><div>As to where the README over at github indicates that this means MapServer.dll can't be found.</div><div><br></div><div>In order to rule out possible issues, I also tried the following:</div><div><br></div><div>- Not creating a venv, but using it with the QGIS python version directly</div><div>- Installing MapScript into normal installations of python 3.7, 3.8, 3.9, 3.10</div><div>- Using it together with the latest builds of MapServer (1930)</div><div>- Not installing MapScript with pip but copying over mapscript.py and _mapscript.pyd from the respective MapServer builds</div><div>- Adding C:\MapServer\bin to PATH instead of the new env variable</div><div><br></div><div>All with the same result. The only ever combination I got it working is when installing the MapScript globally using python3.6/pip and the old MapServer release-1911 (7.6.1), where I sadly can't import PyQGIS in the version I need.</div><div><br></div><div>What could be the issue here? </div><div><br></div><div>Kind regards, Maëlle</div></div></div>