# Name 'cv2' is not defined

**URL:** <https://forum.opencv.org/t/name-cv2-is-not-defined/4735>\
**Category:** Python\
**Tags:** jupyter\
**Created:** [August 12, 2021, 10:23am UTC](https://forum.opencv.org/t/name-cv2-is-not-defined/4735 "2021-08-12T10:23:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klea](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Klea](https://forum.opencv.org/u/Klea)\
**Post date:** [August 12, 2021, 10:23am UTC](https://forum.opencv.org/t/name-cv2-is-not-defined/4735/1 "2021-08-12T10:23:53Z")

</div>

Hello,  
I am doing a code in python using OpenCV but i am facing with an error. I am looking forward if someone is helping me.  
I have installed OpenCV. When I use Import cv2 everything is okay. But later when I want to use it in cv2.VideoCapture this error is shown.  
name ‘cv2’ is not defined  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/a/a64163b5cb7f01ff75b6dd3c6ff62612c60ab8e7.png)

---

<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:** [August 12, 2021, 10:27am UTC](https://forum.opencv.org/t/name-cv2-is-not-defined/4735/2 "2021-08-12T10:27:32Z")

</div>

you have to either

```
import cv2

```

in the current **cell** ,  
or run another cell importing it before.

---

<div class="post-metadata">

**Author:** ![Klea](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Klea](https://forum.opencv.org/u/Klea)\
**Post date:** [August 12, 2021, 10:28am UTC](https://forum.opencv.org/t/name-cv2-is-not-defined/4735/3 "2021-08-12T10:28:44Z")

</div>

i have done it

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/3/392b246c53bf2e0c15d3fd14ba19f9c64d732d44.png)

---

<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:** [August 12, 2021, 10:31am UTC](https://forum.opencv.org/t/name-cv2-is-not-defined/4735/4 "2021-08-12T10:31:31Z")

</div>

just make sure to **run** cell `[1]` before anything else (order matters !)

(and any time the runtime restarts, you have to run it again)

---

<div class="post-metadata">

**Author:** ![Klea](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Klea](https://forum.opencv.org/u/Klea)\
**Post date:** [August 12, 2021, 10:55am UTC](https://forum.opencv.org/t/name-cv2-is-not-defined/4735/5 "2021-08-12T10:55:54Z")

</div>

thank you very much. it is okay now
