# Unable to deploy Flask app with OpenCV to Cloud Foundry (linux)

**URL:** <https://forum.opencv.org/t/unable-to-deploy-flask-app-with-opencv-to-cloud-foundry-linux/3781>\
**Category:** Python\
**Tags:** flask\
**Created:** [June 10, 2021, 5:10pm UTC](https://forum.opencv.org/t/unable-to-deploy-flask-app-with-opencv-to-cloud-foundry-linux/3781 "2021-06-10T17:10:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gooohjy](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gooohjy](https://forum.opencv.org/u/gooohjy)\
**Post date:** [June 10, 2021, 5:10pm UTC](https://forum.opencv.org/t/unable-to-deploy-flask-app-with-opencv-to-cloud-foundry-linux/3781/1 "2021-06-10T17:10:49Z")

</div>

I am currently developing a Python Flask app on Windows, but deploying to Cloud Foundry on linux. I was able to successfully deploy the app before I integrated opencv for additional features. Application is also successfully running on local.

I am using Python 3.6.7 and the first error I’ve encountered was [`ImportError: libGL.so.1: cannot open shared object file: No such file or directory`](https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo).

After trying upgrading and downgrading to various Python versions, the current error is that there is an extremely long time when deploying the application which will result in a timeout error as seen below.

```auto
...
Running setup.py install for future: started
              Running setup.py install for future: finished with status 'done'
            Running setup.py install for pyxnat: started
              Running setup.py install for pyxnat: finished with status 'done'
            The script flask is installed in '/tmp/contents787828360/deps/0/python/bin' which is not on PATH.
            Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
            The scripts imageio_download_bin and imageio_remove_bin are installed in '/tmp/contents787828360/deps/0/python/bin' which is not on PATH.
            Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
            The script jsonpath_ng is installed in '/tmp/contents787828360/deps/0/python/bin' which is not on PATH.
            Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
            Running setup.py install for opencv-python: started
              Running setup.py install for opencv-python: still running...
              Running setup.py install for opencv-python: still running...
              Running setup.py install for opencv-python: still running...
              Running setup.py install for opencv-python: still running...
              Running setup.py install for opencv-python: still running...
              Running setup.py install for opencv-python: still running...
              Running setup.py install for opencv-python: still running...
              Running setup.py install for opencv-python: still running...

```

I have tried changing from opencv-python to opencv-python-headless (unable to run on windows local) and opencv-contrib-python (same issue when deploying). Also tried adding an Aptfile and tuning various OpenCV versions but to no avail.

Currently my issue is that the build has failed during deployment. Any insights will really help thank you.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [June 10, 2021, 5:21pm UTC](https://forum.opencv.org/t/unable-to-deploy-flask-app-with-opencv-to-cloud-foundry-linux/3781/2 "2021-06-10T17:21:04Z")

</div>

> [@gooohjy](#):
>
> opencv-python-headless (unable to run on windows local)

that seems to be the way to go. what exactly went wrong, locally ?  
how exactly are you trying to install it ? (it probably should not _build_ anything)  
(and which opencv version is it ?)

---

<div class="post-metadata">

**Author:** ![gooohjy](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gooohjy](https://forum.opencv.org/u/gooohjy)\
**Post date:** [June 10, 2021, 5:54pm UTC](https://forum.opencv.org/t/unable-to-deploy-flask-app-with-opencv-to-cloud-foundry-linux/3781/3 "2021-06-10T17:54:24Z")

</div>

I am currently using 4.3.0.38 which was chosen randomly. Initially I installed opencv without specifying the version and it was 4.5.2.52 but during deployment I got this warning, which resulted me in downgrading it.

```auto
Could not find a version that satisfies the requirement opencv-python==4.5.2.54 (from -r /tmp/app/requirements.txt (line 32)) (from versions: 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18, 3.4.4.19, 3.4.5.20, 3.4.6.27, 3.4.7.28, 3.4.8.29, 3.4.9.31, 3.4.9.33, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 4.0.0.21, 4.0.1.23, 4.0.1.24, 4.1.0.25, 4.1.1.26, 4.1.2.30, 4.2.0.32, 4.2.0.34, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48)

```

Actually I just checked again, the opencv-python-headless is now working fine but faces the same issue of the timeout error during the app deployment. Build may not be a correct word sorry! I just pip install the package.

I’ve read [elsewhere](https://github.com/3b1b/manim/issues/1213) that this can possibly be resolved with pip upgrade but it’s not easily achievable in Cloud Foundry (unlike local com).

Any idea why the deployment is having a time out error running the setup.py?

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [June 10, 2021, 5:57pm UTC](https://forum.opencv.org/t/unable-to-deploy-flask-app-with-opencv-to-cloud-foundry-linux/3781/4 "2021-06-10T17:57:11Z")

</div>

> [@gooohjy](#):
>
> Build may not be a correct word sorry! I just pip install the package.

hmm, if there’s no adequate prebuilt package for that platform / opencv version, it might indeed try to build it from src, which may take up to 2 hours

---

<div class="post-metadata">

**Author:** ![gooohjy](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gooohjy](https://forum.opencv.org/u/gooohjy)\
**Post date:** [June 10, 2021, 6:07pm UTC](https://forum.opencv.org/t/unable-to-deploy-flask-app-with-opencv-to-cloud-foundry-linux/3781/5 "2021-06-10T18:07:03Z")

</div>

Is there any way I can work around this? Perhaps installing the package via a url or different format within my requirements.txt?

With reference to my previous reply, they returned a message saying that my opencv does not satisfy the versions that they accept. Does that mean that the platform accepts the specific versions because it’s included in a prebuilt package?

The timeout happens after 15mins and hours for deployment is too long unfortunately… 🥶
