# Python: import cv2 .. No module named 'cv2'

**URL:** <https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808>\
**Category:** Support\
**Created:** [11 January 2026 14:05 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808 "2026-01-11T14:05:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [11 January 2026 14:05 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/1 "2026-01-11T14:05:19Z")

</div>

pip install opencv-python

it says:

Successfully installed numpy and opencv-python

Good.

I then run .py:

import cv2

It says:

No module named ‘cv2’

What am I doing wrong?

🙂

---

<div class="post-metadata">

**Author:** ![Pixmusix](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/pixmusix/32/9719_2.png) [@Pixmusix](https://forum.core-electronics.com.au/u/Pixmusix)\
**Post date:** [11 January 2026 22:57 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/2 "2026-01-11T22:57:19Z")

</div>

What OS are you on? 🙂  
If your on raspberryPiOS it may be you need to set up an environment where the modules can be sand-boxed for your code.

---

<div class="post-metadata">

**Author:** ![Jane](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jane/32/12622_2.png) [@Jane](https://forum.core-electronics.com.au/u/Jane)\
**Post date:** [12 January 2026 03:08 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/3 "2026-01-12T03:08:17Z")

</div>

Hey there, @Bill293536.

As Pixmusix said, it could be down to a Virtual Environment issue, but I’m curious what tutorial are you using?

Every tutorial I have seen on using opencv asks uses to manually download the opencv from github. I’ve never seen any guide recommend installing it via pip.

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [12 January 2026 09:44 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/4 "2026-01-12T09:44:09Z")

</div>

Pixmusic, Jane,

Thank you.

I will do core opencv again and see if that helps.

🙂

Bill

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [12 January 2026 13:33 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/5 "2026-01-12T13:33:43Z")

</div>

Pixmusic, Jane,

It works!

I now have a problem.

☹

from picamera2 import Picamera2

No module named ‘libcamera.\_libcamera’

What do I do?

🙂

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [12 January 2026 13:39 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/6 "2026-01-12T13:39:25Z")

</div>

# **Just so you have: How to set up YOLO Computer Vision on a Raspberry Pi | Conda & Ultralytics**

---

<div class="post-metadata">

**Author:** ![Pixmusix](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/pixmusix/32/9719_2.png) [@Pixmusix](https://forum.core-electronics.com.au/u/Pixmusix)\
**Post date:** [12 January 2026 22:54 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/7 "2026-01-12T22:54:20Z")

</div>

> [@Bill293536](#):
>
> No module named ‘libcamera.\_libcamera’

Easy fix, you just need to install it.

From context I think you are using Raspberry Pi Os.  
I’ve learned that, as a rule of thumb, if the package has “lib” in the name it probably wants to be installed system wide. On Debian based systems, like RP Os, **apt** is right tool for this.

```auto
sudo apt install python3-libcamera

```

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [13 January 2026 09:30 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/8 "2026-01-13T09:30:24Z")

</div>

Pixmusix,

I put the:

sudo apt install python3-libcamera

into the Terminal, and the last item is:

python3-libcamera set to manually installed

Is still fails of:

from picamzero import Camera

☹

What should I do?

🙂

---

<div class="post-metadata">

**Author:** ![Jane](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jane/32/12622_2.png) [@Jane](https://forum.core-electronics.com.au/u/Jane)\
**Post date:** [13 January 2026 23:32 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/9 "2026-01-13T23:32:16Z")

</div>

Hey @Bill293536,

I noticed that your error message occured on a different import than previously. In your last post, you said:

> [@Bill293536](#):
>
> from picamera2 import Picamera2
> 
> No module named ‘libcamera.\_libcamera’

But in this reply, you said the error is on:

> [@Bill293536](#):
>
> from picamzero import Camera

1. Have you changed anything else in the intervening time between your last post and now.
2. Could you post a screenshot of the exact error message that you are receiving?
3. Can I just confirm as well that when you did this command as in the tutorial:

```auto
echo '/usr/lib/python3/dist-packages' > /home/pi/miniforge3/envs/ultralytics-env/lib/python3.11/site-packages/system-packages.pth

```

That you replaced the ‘pi’ directory with the home directory that you’re using on the Pi.

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [14 January 2026 13:35 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/10 "2026-01-14T13:35:42Z")

</div>

Jane,

Thank you.

🙂

Right,

**ra5@ra5:~ $ sudo apt install python3-libcamera**

The result was:

**…python3-libcamera set to manually installed**

What should I do?

My .py (Python) was:

**from picamzero import Camera**

Shell:

…

**from .\_libcamera import \***

**ModuleNotFoundError: No module named ‘libcamera.\_libcamera’**

What should I do?

🙂

Bill

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [14 January 2026 21:39 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/11 "2026-01-14T21:39:46Z")

</div>

> [@Jane](#):
>
> `echo '/usr/lib/python3/dist-packages' > /home/pi/miniforge3/envs/ultralytics-env/lib/python3.11/site-packages/system-packages.pth`

pi → ra5

---

<div class="post-metadata">

**Author:** ![Jane](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jane/32/12622_2.png) [@Jane](https://forum.core-electronics.com.au/u/Jane)\
**Post date:** [14 January 2026 23:24 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/12 "2026-01-14T23:24:40Z")

</div>

Hey there, Bill,

Are you sure that it’s meant to be:

```auto
from picamzero import Camera

```

If you’re using this [guide](https://core-electronics.com.au/guides/how-to-set-up-yolo-computer-vision-on-a-raspberry-pi-conda-and-ultralytics/) then the module is listed as picamerazero2 and the import command is:

```auto
from picamera2 import Picamera2

```

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [15 January 2026 11:19 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/13 "2026-01-15T11:19:31Z")

</div>

Jane,

Thank you.

Uniformity, both give the same result!

**ModuleNotFoundError: No module named ‘libcamera.\_libcamera’**

Both:

from picamzero import Camera

and

from picamera2 import Picamera2

What do you think I should do?

🙂

Bill

---

<div class="post-metadata">

**Author:** ![Samuel](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/samuel/32/11763_2.png) [@Samuel](https://forum.core-electronics.com.au/u/Samuel)\
**Post date:** [16 January 2026 00:42 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/14 "2026-01-16T00:42:37Z")

</div>

Hi Bill,

Lets take a step back and make sure all the pieces are in the right place.

The following command will check to see if the \_libcamera module is on your system:

`dpkg -L python3-libcamera | grep _libcamera`

If this returns nothing then -libcamera is not properly installed on your system, in which case you should try installing python3-libcamera again.

Another common cause of this is having your code and modules be on different sides of a virtual environment. The following terminal commands will run a quick test to see if this works from a command line:

`python3 -c "import libcamera; print('libcamera ok')"`

`python3 -c "from picamzero import Camera; print('picamzero ok')"`

if everything is set up correctly, these commands should both work without errors from inside of your virtual environment.

Let us know how this goes!

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [16 January 2026 09:14 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/15 "2026-01-16T09:14:40Z")

</div>

Hi Samuel,

I had tried the commands you listed.

🙂

The first one listed the .libcam

🙂

The second and the third listed:

No module named: libcam

☹

(ultralytics-env) ra5@ra5

What should I do?

Bill

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [17 January 2026 13:00 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/16 "2026-01-17T13:00:04Z")

</div>

> [@Bill293536](#):
>
> (ultralytics-env) ra5@ra5:~$ sudo apt install -y python3-libcamera
> 
> python3-libcamera is already the newest version.

`python3 -c "import libcamera; print('libcamera ok')"`

`python3 -c "from picamzero import Camera; print('picamzero ok')"`

Both give:

ModuleNotFoundError: No module named ‘libcamera.\_libcamera’

What should I do?

🙂

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [18 January 2026 10:35 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/17 "2026-01-18T10:35:36Z")

</div>

…

Thonny→Run→Configure interpreter→

Python executable:

/home/ra5/miniforge3/envs/ultralytics-env/bin/python

---

<div class="post-metadata">

**Author:** ![Samuel](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/samuel/32/11763_2.png) [@Samuel](https://forum.core-electronics.com.au/u/Samuel)\
**Post date:** [18 January 2026 23:57 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/18 "2026-01-18T23:57:04Z")

</div>

Hey @Bill293536 ,

Thanks for checking that! It seems like you may have a few conflicting versions of libcamera floating around on your system.

Your system-wide install of libcamera seems to be there based on the result of the first command, which should include \_libcamera. The result you get from the following commands is only a module not found error, which indicates that you also have another libcamera version (likely installed using the PIP method), which doesn’t have the correct module for your use case.

The best way to get around all this would be to start from the beginning with a fresh install. Would it be possible for you to reimage your Pi’s SD card so that we can be sure you don’t have any unexpected libcamera installations floating around?

---

<div class="post-metadata">

**Author:** ![Bill293536](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bill293536](https://forum.core-electronics.com.au/u/Bill293536)\
**Post date:** [19 January 2026 16:11 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/19 "2026-01-19T16:11:32Z")

</div>

☹

“The best way to get around all this would be to start from the beginning with a fresh install. Would it be possible for you to reimage your Pi’s SD card so that we can be sure you don’t have any unexpected libcamera installations floating around?”

Very, very carefully…

I still have:

picamera2/libcamera

ModuleNotFoundError: No module named ‘libcamera.\_libcamera”

Oh dear!

What can I do?

☹

---

<div class="post-metadata">

**Author:** ![Pixmusix](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/pixmusix/32/9719_2.png) [@Pixmusix](https://forum.core-electronics.com.au/u/Pixmusix)\
**Post date:** [19 January 2026 23:09 UTC](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808/20 "2026-01-19T23:09:31Z")

</div>

What happens when you try installing the below?

```auto
sudo apt install -y python3-libcamera

```

Looks like Raspberry Pi Org have there own code base for python implementations of libcamera.  
Maybe that’s what python is looking for? 🤷‍♂️🤷‍♂️

> **[GitHub - raspberrypi/pylibcamera](https://github.com/raspberrypi/pylibcamera)**
>
> Contribute to raspberrypi/pylibcamera development by creating an account on GitHub.

[Next page](https://forum.core-electronics.com.au/t/python-import-cv2-no-module-named-cv2/23808.md?page=2)
