<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi Aditya,</div><div><br></div><div>Are you building MapScript yourself or using "sudo apt-get install python-mapscript" - see notes under "Installation on Unix" at <a href="https://pypi.org/project/mapscript/">https://pypi.org/project/mapscript/</a></div><div><br></div><div>"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)?<br></div><div><br></div><div>Python 3.9 is as yet untested/supported, but this may not be the cause issue.<br></div><div><br></div><div>Seth<br></div><div><br></div><div id="sig62266145"><div class="signature">--<br></div><div class="signature">web:http://geographika.co.uk<br></div><div class="signature">twitter: @geographika<br></div></div><div><br></div><div><br></div><div>On Mon, Feb 8, 2021, at 10:19 AM, aditya kudekar wrote:<br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div class="qt-gmail-s-prose qt-gmail-js-post-body"><p>I have a simple flask app and I am trying to run in Docker<br></p><pre class="qt-gmail-lang-py qt-gmail-s-code-block qt-gmail-hljs qt-gmail-python"><code><span class="qt-gmail-hljs-keyword">import</span> mapscript
<span class="qt-gmail-hljs-keyword">from</span> flask <span class="qt-gmail-hljs-keyword">import</span> Flask
<span class="qt-gmail-hljs-keyword">import</span> json

app = Flask(__name__)
port = <span class="qt-gmail-hljs-number">5000</span>

<span class="qt-gmail-hljs-meta">@app.route(<span class="qt-gmail-hljs-params"><span class="qt-gmail-hljs-string">"/hello"</span></span>)</span>
<span class="qt-gmail-hljs-function"><span class="qt-gmail-hljs-keyword">def</span> <span class="qt-gmail-hljs-title">geocoder</span>():</span>


    epsg = mapscript.pointObj(<span class="qt-gmail-hljs-number">1</span>, <span class="qt-gmail-hljs-number">1</span>)
    <span class="qt-gmail-hljs-keyword">return</span> json.dumps(epsg)

    test()

<span class="qt-gmail-hljs-keyword">if</span> __name__ == <span class="qt-gmail-hljs-string">'__main__'</span>:
    app.run(host=<span class="qt-gmail-hljs-string">"0.0.0.0"</span>, port=port)
</code><br></pre><p>My Dockerfile is:<br></p><pre class="qt-gmail-lang-py qt-gmail-s-code-block qt-gmail-hljs qt-gmail-python"><code>FROM python

WORKDIR /opt/demo/
COPY /app .

RUN pip install -r requirements.txt

ENTRYPOINT python test.py
</code><br></pre><p>But I get the following error when I run <code>docker run -p 5000:5000 test:latest</code>:<br></p><pre class="qt-gmail-lang-py qt-gmail-s-code-block qt-gmail-hljs qt-gmail-python"><code>Traceback (most recent call last):
  File <span class="qt-gmail-hljs-string">"/opt/demo/test.py"</span>, line <span class="qt-gmail-hljs-number">1</span>, <span class="qt-gmail-hljs-keyword">in</span> <module>
    <span class="qt-gmail-hljs-keyword">import</span> mapscript
  File <span class="qt-gmail-hljs-string">"/usr/local/lib/python3.9/site-packages/mapscript/__init__.py"</span>, line <span class="qt-gmail-hljs-number">2</span>, <span class="qt-gmail-hljs-keyword">in</span> <module>
    <span class="qt-gmail-hljs-keyword">from</span> .mapscript <span class="qt-gmail-hljs-keyword">import</span> *
  File <span class="qt-gmail-hljs-string">"/usr/local/lib/python3.9/site-packages/mapscript/mapscript.py"</span>, line <span class="qt-gmail-hljs-number">13</span>, <span class="qt-gmail-hljs-keyword">in</span> <module>
    <span class="qt-gmail-hljs-keyword">from</span> . <span class="qt-gmail-hljs-keyword">import</span> _mapscript
ImportError: cannot <span class="qt-gmail-hljs-keyword">import</span> name <span class="qt-gmail-hljs-string">'_mapscript'</span> <span class="qt-gmail-hljs-keyword">from</span> partially initialized module <span class="qt-gmail-hljs-string">'mapscript'</span> (most likely due to a circular <span class="qt-gmail-hljs-keyword">import</span>) (/usr/local/lib/python3<span class="qt-gmail-hljs-number">.9</span>/site-packages/mapscript/__init__.py)
</code><br></pre><p>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.<br></p></div><div><div dir="ltr" class="qt-gmail_signature"><div dir="ltr"><div>Warm Regards<br></div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><br></div></div></div></div></div></div></div></div></div><div>Aditya Rajendra Kudekar<br></div></div></div></div></div><div>_______________________________________________<br></div><div>mapserver-users mailing list<br></div><div><a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br></div><div><a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div><div><br></div></blockquote><div><br></div></body></html>