<div dir="ltr"><div class="gmail-s-prose gmail-js-post-body">
<p>I have a simple flask app and I am trying to run in Docker</p>
<pre class="gmail-lang-py gmail-s-code-block gmail-hljs gmail-python"><code><span class="gmail-hljs-keyword">import</span> mapscript
<span class="gmail-hljs-keyword">from</span> flask <span class="gmail-hljs-keyword">import</span> Flask
<span class="gmail-hljs-keyword">import</span> json
app = Flask(__name__)
port = <span class="gmail-hljs-number">5000</span>
<span class="gmail-hljs-meta">@app.route(<span class="gmail-hljs-params"><span class="gmail-hljs-string">"/hello"</span></span>)</span>
<span class="gmail-hljs-function"><span class="gmail-hljs-keyword">def</span> <span class="gmail-hljs-title">geocoder</span>():</span>
epsg = mapscript.pointObj(<span class="gmail-hljs-number">1</span>, <span class="gmail-hljs-number">1</span>)
<span class="gmail-hljs-keyword">return</span> json.dumps(epsg)
test()
<span class="gmail-hljs-keyword">if</span> __name__ == <span class="gmail-hljs-string">'__main__'</span>:
app.run(host=<span class="gmail-hljs-string">"0.0.0.0"</span>, port=port)
</code></pre>
<p>My Dockerfile is:</p>
<pre class="gmail-lang-py gmail-s-code-block gmail-hljs gmail-python"><code>FROM python
WORKDIR /opt/demo/
COPY /app .
RUN pip install -r requirements.txt
ENTRYPOINT python test.py
</code></pre>
<p>But I get the following error when I run <code>docker run -p 5000:5000 test:latest</code>:</p>
<pre class="gmail-lang-py gmail-s-code-block gmail-hljs gmail-python"><code>Traceback (most recent call last):
File <span class="gmail-hljs-string">"/opt/demo/test.py"</span>, line <span class="gmail-hljs-number">1</span>, <span class="gmail-hljs-keyword">in</span> <module>
<span class="gmail-hljs-keyword">import</span> mapscript
File <span class="gmail-hljs-string">"/usr/local/lib/python3.9/site-packages/mapscript/__init__.py"</span>, line <span class="gmail-hljs-number">2</span>, <span class="gmail-hljs-keyword">in</span> <module>
<span class="gmail-hljs-keyword">from</span> .mapscript <span class="gmail-hljs-keyword">import</span> *
File <span class="gmail-hljs-string">"/usr/local/lib/python3.9/site-packages/mapscript/mapscript.py"</span>, line <span class="gmail-hljs-number">13</span>, <span class="gmail-hljs-keyword">in</span> <module>
<span class="gmail-hljs-keyword">from</span> . <span class="gmail-hljs-keyword">import</span> _mapscript
ImportError: cannot <span class="gmail-hljs-keyword">import</span> name <span class="gmail-hljs-string">'_mapscript'</span> <span class="gmail-hljs-keyword">from</span> partially initialized module <span class="gmail-hljs-string">'mapscript'</span> (most likely due to a circular <span class="gmail-hljs-keyword">import</span>) (/usr/local/lib/python3<span class="gmail-hljs-number">.9</span>/site-packages/mapscript/__init__.py)
</code></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.</p>
</div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Warm Regards<div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div></div></div></div></div></div></div></div></div></div><div>Aditya Rajendra Kudekar</div></div></div></div></div>