[mapserver-users] MapScript import errors (Module not found) in Python venv with global install

maëlle lapriel maelscuttle at gmail.com
Fri Apr 29 01:02:02 PDT 2022


Maybe to add (and also because I forgot to add the mailing list to the
recipients) - sadly using Mappyfile isn't really an option, as I'm
intending to use the SLD-specific features of MapScript.

On Fri, 29 Apr 2022 at 09:08, maëlle lapriel <maelscuttle at gmail.com> wrote:

> Hi Seth,
>
> I've considered this to be the problem, however I can rule out any
> dependency conflicts already since I also tried to simply just get
> MapScript running in a Python env without any other imports.
> Am I assuming right that for just using MapScript alone, I can just run
> the SDKShell.bat to have all the variables set, then take a Python version
> that matches the GISInternals build and I'm good to go? Because that
> already yields mentioned import errors, with every possible build or Python
> version except 3.6 and MapServer 7.6.1, which also stops working as soon as
> I set up a venv.
>
> Thank you very much for your help.
>
> Cheers
>
> On Thu, Apr 28, 2022, 18:25 Seth G <sethg at geographika.co.uk> wrote:
>
>> Hi Maëlle,
>>
>> MapScript (and MapServer) use many of the same dependent DLLs as QGIS -
>> GDAL, Proj, GEOS etc. which would then get loaded into memory by Python.
>> For everything to work correctly, all these dependencies would have to be
>> the same version, and (I think this is still the case), compiled with the
>> same version of Microsoft Visual C (the 1928, 1931 etc. use when naming the
>> GISInternals zips).
>> It probably would be possible to get everything build and working, but
>> you'd likely have to compile everything yourself.
>> Is it possible to modify your workflow so a PyQGIS environment dumps out
>> data to disk and then a MapScript environment works on this data?
>> I'd imagine PyQGIS can probably do everything MapScript can, except for
>> manipulate Mapfiles - you could take a look at mappyfile for this, which is
>> Python only has has no dependent DLLs.
>>
>> Seth
>>
>> --
>> web:https://geographika.net
>> twitter: @geographika
>>
>>
>> On Thu, Apr 28, 2022, at 11:42 AM, maëlle lapriel wrote:
>>
>> I'm trying to write a PyQGIS standalone script which utilizes MapScript
>> for certain tasks. In a first attempt, I basically did this:
>>
>> - I installed MapScript globally with pip and using the Python 3.9.5
>> interpreter which ships with QGIS 3.22.6 (also includes wheel)
>> - Created a venv with --system-site-packages
>> - Downloaded the appropriate Windows binary build of MapServer from
>> GISInternals (release-1928-x64-gdal-3-4-mapserver-7-6) and extracted into
>> C:\MapServer\
>> - Set the MAPSERVER_DLL_PATH to C:\MapServer\bin
>>
>> However, whenever I try to load MapScript, it yields the following:
>>
>> Traceback (most recent call last):
>>   File "<string>", line 1, in <module>
>>   File "C:\QGIS\apps\Python39\lib\site-packages\mapscript\__init__.py",
>> line 2, in <module>
>>     from .mapscript import *
>>   File "C:\QGIS\apps\Python39\lib\site-packages\mapscript\mapscript.py",
>> line 13, in <module>
>>     from . import _mapscript
>> ImportError: DLL load failed while importing _mapscript: The specified
>> module could not be found.
>>
>> As to where the README over at github indicates that this means
>> MapServer.dll can't be found.
>>
>> In order to rule out possible issues, I also tried the following:
>>
>> - Not creating a venv, but using it with the QGIS python version directly
>> - Installing MapScript into normal installations of python 3.7, 3.8, 3.9,
>> 3.10
>> - Using it together with the latest builds of MapServer (1930)
>> - Not installing MapScript with pip but copying over mapscript.py and
>> _mapscript.pyd from the respective MapServer builds
>> - Adding C:\MapServer\bin to PATH instead of the new env variable
>>
>> 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.
>>
>> What could be the issue here?
>>
>> Kind regards, Maëlle
>> _______________________________________________
>> MapServer-users mailing list
>> MapServer-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20220429/d35b95a0/attachment.htm>


More information about the MapServer-users mailing list