Trying to install StickerBOM, Python Module cairo

I searched for a Plugin/Script that can export the BOM into labels to mark my component bags as they come from mouser. I found StickerBOM on GitHub. I tried to run the script by adding it to the BOM generator scripts in the Schematic Editor. Then i got this output:

File "C:\script_location\agg-kicad-master\scripts\stickerbom.py", line 14, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'

Then i tried installing cairo with pip, so i opened the KiCad 6.0 Command Prompt and typed pip install pycairo as i believe is the right version. But the module cairo is still not found.

Does someone know where the python modules for KiCad are located?
Or does someone know how i can check which modules python knows?
Is there another know plugin/script which can generate labels?

Thanks for your help.

KiCad Installation:

Application: KiCad (64-bit)

Version: (6.0.8), release build

Libraries:
	wxWidgets 3.1.7
	libcurl/7.83.1-DEV Schannel zlib/1.2.12

Platform: Windows 10 (build 19044), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
	Date: Sep 29 2022 00:21:26
	wxWidgets: 3.1.7 (wchar_t,wx containers)
	Boost: 1.79.0
	OCC: 7.6.0
	Curl: 7.83.1-DEV
	ngspice: 37
	Compiler: Visual C++ 1929 without C++ ABI

Build settings:
	KICAD_USE_OCC=ON
	KICAD_SPICE=ON

Check the InteractiveHtmlBom plugin. It doesn’t print a diagram per bom item but is designed to help with manual assembly. You can install it from KiCad’s built in plugin manager.

Regarding StickerBOM, you should specify path to KiCad’s own python (...\KiCad\bin\python.exe) in the eeschema bom generator command line. If you just put python it will likely pick system default one instead.
KiCad’s python will find cairo module you installed.

InteractiveHtmlBom is great, I already use it.

My goal is to find a way to mark all my bags with the components with a label.
I changed the command line like this:
C:\Program Files\KiCad\6.0\bin\python.exe "C:\03_Data\repos_external\git\agg-kicad\scripts/stickerbom.py" "%I" "%O"

Is that what you meant?

I still get the same error.

File "C:\script_location\agg-kicad-master\scripts\stickerbom.py", line 14, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'

Command line as you pasted it would not work because of space in the path. You should put the python path in quotes.

Other than that it looks correct. If pip install pycairo succeeded in kicad command prompt then I am not sure what else could be the reason for that error.

Try opening issue on the script github if the quotes don’t help.

I tried that to and I found out it does not make a difference.
With: C:\Program Files\KiCad\6.0\bin\python.exe "C:\03_Data\repos_external\git\agg-kicad\scripts/stickerbom.py" "%I" "%O"
Output:

C:\Program Files\KiCad\6.0\bin\python.exe "C:\03_Data\repos_external\git\agg-kicad\scripts/stickerbom.py" "C:\03_Data\repos\SVN\TestAutomation\TestAdapter\SNIFX\SNIFX.QP2\2_KiCad\SNIFX.xml" "C:/03_Data/repos/SVN/TestAutomation/TestAdapter/SNIFX/SNIFX.QP2/2_KiCad/SNIFX"
Command error. Return code 1.
Traceback (most recent call last):
  File "C:\03_Data\repos_external\git\agg-kicad\scripts\stickerbom.py", line 14, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'

With: "C:\Program Files\KiCad\6.0\bin\python.exe" "C:\03_Data\repos_external\git\agg-kicad\scripts/stickerbom.py" "%I" "%O"
Output:

"C:\Program Files\KiCad\6.0\bin\python.exe" "C:\03_Data\repos_external\git\agg-kicad\scripts/stickerbom.py" "C:\03_Data\repos\SVN\TestAutomation\TestAdapter\SNIFX\SNIFX.QP2\2_KiCad\SNIFX.xml" "C:/03_Data/repos/SVN/TestAutomation/TestAdapter/SNIFX/SNIFX.QP2/2_KiCad/SNIFX"
Command error. Return code 1.
Traceback (most recent call last):
  File "C:\03_Data\repos_external\git\agg-kicad\scripts\stickerbom.py", line 14, in <module>
    import cairo
ModuleNotFoundError: No module named 'cairo'

I managed to run the script from windows command line with the python installation on the system. Returned an other error and therefore raised and issue on the script GitHub page.

Thanks for your help.

I think, that you need to install the module cairo in the python of kicad.
For that you should start the kicad command line (from the windows start menu). then call pip install cairo.

Note, it is just an idea, I haven’t tried, and I’m not very good with python.

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