<p>I have read similar questions regarding azure app service, but I still can't find an answer. I was trying to deploy a model in azure kubernetes service, but I came across an error when importing cv2 (which is essential to me).</p>
<p>Opencv-python is included in my environment .yaml file:</p>
<pre><code>name: project_environment
dependencies:
  # The python interpreter version.
  # Currently Azure ML only supports 3.5.2 and later.
- python=3.6.2

- pip:
  # You must list azureml-defaults as a pip dependency
  - azureml-defaults&gt;=1.0.45
  - Cython
  - matplotlib&gt;=3.2.2
  - numpy&gt;=1.18.5
  - opencv-python&gt;=4.1.2
  - pillow
  - PyYAML&gt;=5.3
  - scipy&gt;=1.4.1
  - torch&gt;=1.6.0
  - torchvision&gt;=0.7.0
  - tqdm&gt;=4.41.0
channels:
- conda-forge
</code></pre>
<p>I am deploying as follows:</p>
<pre><code>aks_service = Model.deploy(ws,
                       models=[model],
                       inference_config=inference_config,
                       deployment_config=gpu_aks_config,
                       deployment_target=aks_target,
                       name=aks_service_name)
</code></pre>
<p>And I get this error:</p>
<pre><code>    Traceback (most recent call last):
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/gunicorn/arbiter.py&quot;, line 583, in spawn_worker
    worker.init_process()
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/gunicorn/workers/base.py&quot;, line 129, in init_process
    self.load_wsgi()
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/gunicorn/workers/base.py&quot;, line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/gunicorn/app/base.py&quot;, line 67, in wsgi
    self.callable = self.load()
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py&quot;, line 52, in load
    return self.load_wsgiapp()
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py&quot;, line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/gunicorn/util.py&quot;, line 350, in import_app
    __import__(module)
  File &quot;/var/azureml-server/wsgi.py&quot;, line 1, in &lt;module&gt;
    import create_app
  File &quot;/var/azureml-server/create_app.py&quot;, line 3, in &lt;module&gt;
    from app import main
  File &quot;/var/azureml-server/app.py&quot;, line 32, in &lt;module&gt;
    from aml_blueprint import AMLBlueprint
  File &quot;/var/azureml-server/aml_blueprint.py&quot;, line 23, in &lt;module&gt;
    main_module_spec.loader.exec_module(main)
  File &quot;/var/azureml-app/score.py&quot;, line 8, in &lt;module&gt;
    import cv2
  File &quot;/azureml-envs/azureml_659b55e5b05510a45f41f0ca31d3ac02/lib/python3.6/site-packages/cv2/__init__.py&quot;, line 5, in &lt;module&gt;
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Worker exiting (pid: 41)
</code></pre>

Fjord
<p>This might go wrong at some point, but my workaround was installing opencv-python-headless instead of opencv.</p>
<p>In the environment .yaml file, just replace:</p>
<pre><code>- opencv-python&gt;=4.1.2
</code></pre>
<p>with:</p>
<pre><code>- opencv-python-headless
</code></pre>
