# Cpython bug?! include path break after rgbmatrix()

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/cpython-bug-include-path-break-after-rgbmatrix/1053>\
**Category:** Uncategorized\
**Created:** [April 7, 2025, 9:12am UTC](https://rpi-rgb-led-matrix.discourse.group/t/cpython-bug-include-path-break-after-rgbmatrix/1053 "2025-04-07T09:12:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![overflo](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/overflo/32/469_2.png) [@overflo](https://rpi-rgb-led-matrix.discourse.group/u/overflo)\
**Post date:** [April 7, 2025, 9:12am UTC](https://rpi-rgb-led-matrix.discourse.group/t/cpython-bug-include-path-break-after-rgbmatrix/1053/1 "2025-04-07T09:12:36Z")

</div>

Hi,  
I compiled the python bindings from the github repo  
[GitHub - hzeller/rpi-rgb-led-matrix: Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO](https://github.com/hzeller/rpi-rgb-led-matrix/)

it compiles and i can use it.  
i made a VENV that i use for all those libs.

somehow there is some weird fuckup with the cpython doing strange things to the include path?  
i am not sure where to post this. maybe github issues?

THIS works:  
from PIL import Image  
image.open(“/tmp/foo.png”)

THIS fails:  
import rgbmatrix  
options = rgbmatrix.RGBMatrixOptions()  
options.rows = 64  
options.cols = 64  
options.chain\_length = 2  
options.parallel = 2  
options.brightness = 10  
options.hardware\_mapping = ‘regular’

rgbmatrix.RGBMatrix(options = options)  
\<rgbmatrix.core.RGBMatrix object at 0x7f88c32f50\>

from PIL import Image  
Traceback (most recent call last):  
File “”, line 1, in   
ModuleNotFoundError: No module named ‘PIL’

i made logs with python -v -v

the working one looks like this:

/home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL/ **pycache** / **init**.cpython-311.pyc matches /home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL/ **init**.py  
code object from ‘/home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL/ **pycache** / **init**.cpython-311.pyc’

the failed one looks like this:  
trying /home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL.cpython-311-aarch64-linux-gnu.so trying /home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL.abi3.so  
trying /home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL.so  
trying /home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL.py  
trying /home/pewpew/blinkenschild/venv/lib/python3.11/site-packages/PIL.pyc  
Traceback (most recent call last):  
File “”, line 1, in   
File “”, line 1178, in \_find\_and\_load  
File “”, line 1142, in \_find\_and\_load\_unlocked  
ModuleNotFoundError: No module named ‘PIL’

anyone got any ideas what to do?!

apparently this happens only when i run python in the venv as root?!

---

<div class="post-metadata">

**Author:** ![overflo](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/overflo/32/469_2.png) [@overflo](https://rpi-rgb-led-matrix.discourse.group/u/overflo)\
**Post date:** [April 7, 2025, 11:37am UTC](https://rpi-rgb-led-matrix.discourse.group/t/cpython-bug-include-path-break-after-rgbmatrix/1053/2 "2025-04-07T11:37:40Z")

</div>

**SOLUTION / WORKAROUND**

this is a weird bug that has to do with VENV and opython and not with this library.  
i managed to use a hack to get it running.  
the hack involves setting everything up in VENV but not using it later to run it.  
instead i use

import sys  
sys.path.append(“venv/lib/python3.11/site-packages/”)

and run the script with the python interpreter and paths from the host system.

i THINK the bug happens because rgbmatrix is built and installed systemwide depending on PIL and the venv uses another version of PIL at some point?
