# Problem error import CV2

**URL:** <https://discuss.streamlit.io/t/problem-error-import-cv2/26348>\
**Category:** Community Cloud\
**Tags:** opencv\
**Created:** [June 10, 2022, 11:29am UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348 "2022-06-10T11:29:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcastiblanco1251](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mcastiblanco1251/32/14875_2.png) [@mcastiblanco1251](https://discuss.streamlit.io/u/mcastiblanco1251)\
**Post date:** [June 10, 2022, 11:29am UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/1 "2022-06-10T11:29:07Z")

</div>

Hi:

My streamlit app runs fine locally. I am doing image processing hence using opencv  
But when I deploy the app it says :

```auto
note: This error originates from a subprocess, and is likely not a problem with pip.

```

```auto
  Building wheel for blinker (setup.py): started

```

```auto
  ERROR: Failed building wheel for opencv-python-headless

```

```auto
  Building wheel for blinker (setup.py): finished with status 'done'

```

```auto
  Created wheel for blinker: filename=blinker-1.4-py3-none-any.whl size=13478 sha256=d68f921990555798c44380592087304862ce2c05af5826d0bb78a7b790950ba1

```

```auto
  Stored in directory: /tmp/pip-ephem-wheel-cache-vc3hqmkx/wheels/50/93/f8/4f0a42a03a06626d675f13907b6982ad5ecff383530af5a900

```

```auto
  Building wheel for validators (setup.py): started

```

```auto
  Building wheel for validators (setup.py): finished with status 'done'

```

```auto
  Created wheel for validators: filename=validators-0.20.0-py3-none-any.whl size=19582 sha256=e27f962b0bfe279b95e7f3d2e7c79f3eb6f3e4240e690c4d27ef9e532af307aa

```

```auto
  Stored in directory: /tmp/pip-ephem-wheel-cache-vc3hqmkx/wheels/2d/f0/a8/1094fca7a7e5d0d12ff56e0c64675d72aa5cc81a5fc200e849

```

```auto
Successfully built numpy blinker validators

```

```auto
Failed to build opencv-python-headless

```

```auto
ERROR: Could not build wheels for opencv-python-headless, which is required to install pyproject.toml-based projects

```

I adjust according the recommendations forums before opencv but doesnt work

The entire code is on my github here is the link: [GitHub - mcastiblanco1251/CV: Tratamiento de Imagenes](https://github.com/mcastiblanco1251/CV)  
Any help is appreciated  
Thanks

---

<div class="post-metadata">

**Author:** ![Franky1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/franky1/32/6509_2.png) [@Franky1](https://discuss.streamlit.io/u/Franky1)\
**Post date:** [June 10, 2022, 11:34am UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/2 "2022-06-10T11:34:37Z")

</div>

Use in your `requirements.txt` file:

```auto
opencv-python-headless==4.5.4.60

```

---

<div class="post-metadata">

**Author:** ![mcastiblanco1251](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mcastiblanco1251/32/14875_2.png) [@mcastiblanco1251](https://discuss.streamlit.io/u/mcastiblanco1251)\
**Post date:** [June 10, 2022, 11:49am UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/3 "2022-06-10T11:49:00Z")

</div>

Now it appear this:

```auto
ERROR: Cannot install -r /app/cv/requirements.txt (line 2), -r /app/cv/requirements.txt (line 4) and numpy==1.18.1 because these package versions have conflicting dependencies.

```

```auto

```

```auto
The conflict is caused by:

```

```auto
    The user requested numpy==1.18.1

```

```auto
    pandas 1.1.5 depends on numpy>=1.15.4

```

```auto
    opencv-python-headless 4.5.4.60 depends on numpy>=1.19.3

```

---

<div class="post-metadata">

**Author:** ![Franky1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/franky1/32/6509_2.png) [@Franky1](https://discuss.streamlit.io/u/Franky1)\
**Post date:** [June 10, 2022, 11:51am UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/4 "2022-06-10T11:51:20Z")

</div>

Remove (or update) the version numbers of `pandas` and `numpy` packages, unless you need specifically these older versions.

---

<div class="post-metadata">

**Author:** ![mcastiblanco1251](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mcastiblanco1251/32/14875_2.png) [@mcastiblanco1251](https://discuss.streamlit.io/u/mcastiblanco1251)\
**Post date:** [June 10, 2022, 11:54am UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/5 "2022-06-10T11:54:48Z")

</div>

Thks very much!!

---

<div class="post-metadata">

**Author:** ![mcastiblanco1251](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mcastiblanco1251/32/14875_2.png) [@mcastiblanco1251](https://discuss.streamlit.io/u/mcastiblanco1251)\
**Post date:** [June 10, 2022, 4:10pm UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/6 "2022-06-10T16:10:43Z")

</div>

Now I have this error:

cv2.error: OpenCV(4.5.4) /tmp/pip-req-build-9vck9bv0/opencv/modules/highgui/src/window.cpp:1268: error: (-2:Unspecified error) The function is not implemented.

Do you have a any idea that how solve it?

---

<div class="post-metadata">

**Author:** ![Franky1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/franky1/32/6509_2.png) [@Franky1](https://discuss.streamlit.io/u/Franky1)\
**Post date:** [June 10, 2022, 7:00pm UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/7 "2022-06-10T19:00:09Z")

</div>

You cannot use e.g. `cv2.VideoCapture`, `cv2.imshow`, `cv2.waitKey`, if streamlit runs on a hosted service!

This does not work because there is a fundamental misunderstanding about how Streamlit works.  
Streamlit consists of a frontend and backend part. Any interaction with streamlit must be done via the browser or browser APIs. Anything trying to bypass this, may work on your local computer, but will fail as soon as streamlit is hosted, i.e. streamlit no longer runs on the same computer as the browser.

What happens when you try to open cv2 (or other) gui widgets or try to access video hardware? They will be opened on the computer on which the python application is running. But there is neither an UI nor a graphics driver nor a video device on streamlit cloud and even if there was, it would be the wrong computer.

You have to rethink your whole approach, it will not work this way.

---

<div class="post-metadata">

**Author:** ![mcastiblanco1251](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mcastiblanco1251/32/14875_2.png) [@mcastiblanco1251](https://discuss.streamlit.io/u/mcastiblanco1251)\
**Post date:** [June 10, 2022, 7:14pm UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/8 "2022-06-10T19:14:35Z")

</div>

I got it, thanks again!!!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [June 10, 2023, 7:15pm UTC](https://discuss.streamlit.io/t/problem-error-import-cv2/26348/9 "2023-06-10T19:15:20Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
