# Import error for cv2

**URL:** <https://discuss.huggingface.co/t/import-error-for-cv2/12404>\
**Category:** Spaces\
**Created:** [November 30, 2021, 11:52pm UTC](https://discuss.huggingface.co/t/import-error-for-cv2/12404 "2021-11-30T23:52:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yrodriguezmd](https://avatars.discourse-cdn.com/v4/letter/y/4491bb/32.png) [@yrodriguezmd](https://discuss.huggingface.co/u/yrodriguezmd)\
**Post date:** [November 30, 2021, 11:52pm UTC](https://discuss.huggingface.co/t/import-error-for-cv2/12404/1 "2021-11-30T23:52:20Z")

</div>

I tried using import cv2 and various combinations of opencv and cv2 codes in the requirements.txt as well as the app.py.

I get this ImportError:

```auto
  File "/home/user/.local/lib/python3.8/site-packages/cv2/ __init__.py", line 8, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

```

I’ve seen a couple of Spaces that have the same error, and have not been able to see a Space that does deploy a program with a cv2 successfully. I would suggest leads on how to address this Import Error, or some samples of working code.

Thank you!

Maria

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [December 1, 2021, 8:40am UTC](https://discuss.huggingface.co/t/import-error-for-cv2/12404/2 "2021-12-01T08:40:22Z")

</div>

Hey there!

You can create a `packages.txt` file and use `python3-opencv` there. I think this worked for me last time I checked. Let me know if that works please 🙂

Thanks,  
Omar

---

<div class="post-metadata">

**Author:** ![yrodriguezmd](https://avatars.discourse-cdn.com/v4/letter/y/4491bb/32.png) [@yrodriguezmd](https://discuss.huggingface.co/u/yrodriguezmd)\
**Post date:** [December 3, 2021, 12:58am UTC](https://discuss.huggingface.co/t/import-error-for-cv2/12404/3 "2021-12-03T00:58:29Z")

</div>

Hi @osanseviero, I tried your suggestion, and I think it worked because although I am still getting an error, it is no longer about cv2.

Thank you!

🙂  
Maria

---

<div class="post-metadata">

**Author:** ![yrodriguezmd](https://avatars.discourse-cdn.com/v4/letter/y/4491bb/32.png) [@yrodriguezmd](https://discuss.huggingface.co/u/yrodriguezmd)\
**Post date:** [December 6, 2021, 7:09pm UTC](https://discuss.huggingface.co/t/import-error-for-cv2/12404/4 "2021-12-06T19:09:14Z")

</div>

@osanseviero – I can now confirm that your suggestion was essential in making my project work. Thank you again! 🙂

Maria
