[mapserver-users] Mapscript circular import error inside Python-Flask Docker

Seth G sethg at geographika.co.uk
Tue Feb 9 00:37:51 PST 2021


Hi Aditya,

Are you building MapScript yourself or using "sudo apt-get install python-mapscript" - see notes under "Installation on Unix" at https://pypi.org/project/mapscript/

"This happens only when I have the Python VENV activated when running outside Docker" - do you mean the exact same approach works outside of Docker? Is MapServer installed on Docker (this is required along with mapscript)?

Python 3.9 is as yet untested/supported, but this may not be the cause issue.

Seth

--
web:http://geographika.co.uk
twitter: @geographika


On Mon, Feb 8, 2021, at 10:19 AM, aditya kudekar wrote:
> I have a simple flask app and I am trying to run in Docker

> `import mapscript
> from flask import Flask
> import json

app = Flask(__name__)
port = 5000

> @app.route("/hello")
> def geocoder():


    epsg = mapscript.pointObj(1, 1)
    return json.dumps(epsg)

    test()

> if __name__ == '__main__':
    app.run(host="0.0.0.0", port=port)
`
> My Dockerfile is:

> `FROM python

WORKDIR /opt/demo/
COPY /app .

RUN pip install -r requirements.txt

ENTRYPOINT python test.py
`
> But I get the following error when I run `docker run -p 5000:5000 test:latest`:

> `Traceback (most recent call last):
  File "/opt/demo/test.py", line 1, in <module>
    import mapscript
  File "/usr/local/lib/python3.9/site-packages/mapscript/__init__.py", line 2, in <module>
    from .mapscript import *
  File "/usr/local/lib/python3.9/site-packages/mapscript/mapscript.py", line 13, in <module>
    from . import _mapscript
ImportError: cannot import name '_mapscript' from partially initialized module 'mapscript' (most likely due to a circular import) (/usr/local/lib/python3.9/site-packages/mapscript/__init__.py)
`
> This happens only when I have the Python VENV activated when running outside Docker but I don't know why I am getting this error inside Docker.

> Warm Regards
> 
> Aditya Rajendra Kudekar
> _______________________________________________
> 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/20210209/68d7659e/attachment.html>


More information about the mapserver-users mailing list