Hello, I’ve Installed Kicost but get “Command error. Return code 2” when I try to run it from the BOM popup window… First I tried installing and running several of the BOM scripts included with Kicad, When I run them I get “Command error. Return code 11” . I’m using one of the demo projects
The command line generated by the Kicad BOM popup for Kicost plugin is :“C:\Program Files\KiCad\bin\scripting\plugins\kicost.exe” < “%I” > “%O” , and for the bom_with_title_block_2_csv plugin is : xsltproc -o “%O” “C:\Program Files\KiCad\bin\scripting\plugins\bom_with_title_block_2_csv.xsl” “%I”
The files present in the Plugins folder for Kicost are Kicost, kicost.exe.manifest, and kicost-script
I haven’t tried to run KiCost as a BOM plugin. I always run it as a stand-alone program. One of the things that might be affecting it is that the python packaged with KiCad didn’t have a lot of the modules KiCost needs. (I’m not sure if that’s still the case.)
Also, the command generated for the KiCost plugin is wrong. The input and output files need to be preceded by the “-i” and “-o” flags, respectively.
You might try installing Python 2.7 or Python 3 and then install KiCost. Then try running it as described in the documentation.
Thanks for the quick reply. Yes, I had already installed Python 2.7 before I started. Kicad isn’t even creating the .xml files, so the input file doesn’t even exist. The xsltproc doesn’t even seem to be installed in kicad anywhere.
I’m using the stable-release version of KiCad (4.0.1). I don’t have any plugins when I activate the BOM tool. I just click on the Generate
button. Then I look in my project directory and there’s an XML file with the project name and the .xml file extension. Then I run KiCost on that. The simplest run command would be:
kicost -i my_project.xml
After that command completes, you should have a spreadsheet file called my_project.xlsx.
Thanks! I’m running 4.0.1 as well. Tried your suggestions and had some (limited) success. Had to move project files to a different directory as it didn’t like the space in the “Program Files” directory name. Maybe if I setup the context menu it wouldn’t be a problem? It now creates the BOM .xml file and kicost creates the xls file…I can open it in a spreadsheet but it doesn’t seem to be scraping the suppliers sites as the price columns are empty. I did add the manf# field to several components along with part #'s just to try it out. I wonder if it’s not working because I didn’t add the field to ALL of the components or if there is another issue?
If you want to send me the .xml file, I’ll try running it through my KiCost. devb@xess.com
There are two problems with your XML file:
- Instead of putting the part number in the “manf#” field, you used "manf# " with a trailing space. KiCost didn’t recognize it. I’ll have to put a fix into KiCost for leading/trailing space in field names.
- Even if the label had been correct, KiCost couldn’t have done anything with your part numbers. Transistor Q1 had a part number of 2n2222. That’s way too generic: KiCost can’t pick from a list of hundreds on Digikey. You need a part number for a specific 2n2222 transistor. The same issue applies to the 74hc125.
Hmmm. I looked at all the components that I added the "manf# " field to,
and all the field names have "manf# " and all the field values have part
#'s, couldn’t find any that had "manf# " in value field. The trailing
space likely happened from copy/past. Good to know about the part #'s, I
just threw those #'s in there for testing purposes but didn’t give any
thought to them being to generic.
May someone create a tutorial “how to install KiCost”?
I am trying to install in a Ubuntu 16.04 and miss some required libraries.
First to install I have to install “easy_install” on python, and when I try to install kicost I have the follow error:
Using build configuration of libxslt
src/lxml/lxml.etree.c:84:20: fatal error: Python.h: No such file or directory
compilation terminated.
Compile failed: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
/tmp/easy_install-p4b6mvh5/lxml-3.8.0/temp/xmlXPathInith3rqkqni.c:1:26: fatal error: libxml/xpath.h: No such file or directory
compilation terminated.
After (with I try to use directly the *.py of kicost) I have the erro:
Traceback (most recent call last):
File “kicost.py”, line 28, in
from builtins import zip
I’m running lubuntu which is like Ubuntu 17.04. It has Python 2.7.13 installed. All I had to do to install kicost was type pip install kicost
. I was also able to do it using easy_install kicost
.
It looks like your installation is trying to compile the lxml
library from source. lxml
is available in a pre-compiled form so that shouldn’t be required. You might try this set of commands to install lxml
:
pip install wheel
pip install lxml
After that, pip install kicost
might work.
Thank you
Now is installed, but already with errors to run
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 658, in _build_master
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 972, in require
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 863, in resolve
pkg_resources.ContextualVersionConflict: (lxml 3.5.0 (/usr/lib/python3/dist-packages), Requirement.parse(‘lxml>=3.7.2’), {‘kicost’})
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/bin/kicost”, line 6, in
from pkg_resources import load_entry_point
File “”, line 969, in _find_and_load
File “”, line 958, in _find_and_load_unlocked
File “”, line 664, in _load_unlocked
File “”, line 634, in _load_backward_compatible
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 3049, in
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 3033, in _call_aside
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 3062, in _initialize_master_working_set
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 660, in _build_master
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 673, in _build_from_requirements
File “/usr/local/lib/python3.5/dist-packages/setuptools-36.2.7-py3.5.egg/pkg_resources/init.py”, line 858, in resolve
pkg_resources.DistributionNotFound: The ‘lxml>=3.7.2’ distribution was not found and is required by kicost
The actual lxml on python3 is 3.5 how to update by pip to 3.7 (minimum)?
I fixed, forcing to install all the python packages in the “requires.txt” of kicost folder, even the already installed to get the newest versions.
I didn’t know the pip (package manager) of python.