Kicost is amazing tool, but for me it didn't work!

Thanks for hanging in there! Let me know if you have any problems.

I just tried to install it on Win7 x64 with Python 3.4 x64 by using “pip install kicost” from administrator prompt. Then received a long list of build commands (some with warnings), ending in this text (in red color):

----------------------------------------
Cleaning up...
Command C:\Python34_64\python.exe -c "import setuptools, tokenize;__file__='D:\\
Temp\\pip_build_Mark\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', ope
n)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record
D:\Temp\pip-zywsnvlj-record\install-record.txt --single-version-externally-manag
ed --compile failed with error code 1 in D:\Temp\pip_build_Mark\lxml
Storing debug log for failure in C:\Users\Mark\pip\pip.log
----------------------------------------

Trying to run kicost --version or anything else results in:

C:\Windows\system32>kicost --version
Traceback (most recent call last):
  File "C:\Python34_64\Scripts\kicost-script.py", line 5, in <module>
    from pkg_resources import load_entry_point
  File "C:\Python34_64\lib\site-packages\pkg_resources.py", line 2697, in <module>
    working_set.require(__requires__)
  File "C:\Python34_64\lib\site-packages\pkg_resources.py", line 669, in require
    needed = self.resolve(parse_requirements(requirements))
  File "C:\Python34_64\lib\site-packages\pkg_resources.py", line 572, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: yattag>=1.5.2

Any ideas? There is a pip.log file, 309kB.

Yeah, you’re having problems with installing lxml on Windows. Try using easy_install kicost and see if that works better.

Interesting… running “easy_install kicost” scans for yattag, finds v1.5.2, installs it, scans for lxml, finds v3.5.0, installs it, then says this:

Building lxml version 3.5.0.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\n
operable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
error: Setup script exited with error: Unable to find vcvarsall.bat

Trying to run kicost results in almost the same as previous, but finishes with:

    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: lxml>=3.3.3

So it looks like lxml isn’t functional, due to components libxml2 and libxslt not being installed. Okay, so the issue definitely seems to be lxml. Googling it, returns a StackExchange question about it, which essentially points to manually installing a lxml v3.5.0 binary. Note Python 2.6 or 2.7 is mandatory; I have 2.7.9 and 3.4.2 both but think 3 is default. Downloaded the executable, installed it, it demands to be installed in the 2.7 folder. Fine, no errors. Try “easy-install kicost” again, same lxml error. So it is trying to install lxml into 3.4.2 Python, which isn’t working.

“python” executes v3. “py” executes v2… interesting. Googling how to switch between these, a large number of workarounds exist, all of which are rather customized and detailed. Adding PY_PYTHON = 2 env var did nothing.

Uninstalled Python 3.4.2, which uninstalled pip and setuptools…
Now “py” gives 2.7.9, but “python” does nothing. Added C:\Python27_64 to path. Now “python” is working.
NOW tried easy_install kicost, “easy_install” not a recognized command…

Okay here we go… uninstall all of the python versions (2.7.9 x32, 2.7.9 x64). Install JUST 2.7.11 x64 into cleaned-out c:\python27… add to the path, verify working with “python” and “py”, but “easy_install” and “pip” do nothing…

Which according to this question, python’s “scripts” folder also needs to be in the path. Looking in there, sure enough, pip.exe and easy_install.exe are there. So added, did the “easy_install kicost” without error, and “kicost --version” returns:

D:\>kicost --version
KiCost 0.1.14

So it was a python configuration/compatibility issue. Decided to post this in case anyone else ran into these issues and need some guidance in what to try. But to be honest, the configuration may be beyond many users.

1 Like

c:\python27\scripts\kicost.exe pops up in a command window, echoes nothing for a few minutes, then generates the .xlsx file. Opening that, it seems correct (woohoo!), except the components all show #NAME? for Unit$ and Ext$ fields, along with the Total Cost and Unit Cost fields. So prices are not being returned properly. Ideas? I added the -s switch in the registry entry, no change.

EDIT: Think I’ve located the issue. The .xlsx renders fine if opened from dropbox (using their built-in viewer) but not from Apache OpenOffice 4.1.2 for Windows. Looks like it is unable to process the Unit$ column formulas, which leads to math failures elsewhere. The values are in the formulas, but OO doesn’t understand the syntax:

=iferror(LOOKUP(IF(K77="";G77;K77);{0;1;25;100;2500};{0;1.32;1.1;1;0.92});"")

I poked around with this for a bit, and found this post, which explains that “iferror” does not exist in OO (v3 at the time) and that a bug report was made about it (in 2008!) It is still open, marked “trivial” and in no rush to be fixed. Removing the iferror( and ;"") seems to work:

=LOOKUP(IF(K77="";G77;K77);{0;1;25;100;2500};{0;1.32;1.1;1;0.92})

Since these formulas only exist in the spreadsheet lines containing actual data, is the “iferror” redundant? Thanks and apologies for the lengthy verbiage. :slight_smile:

Edit 2… So I wondered why OpenOffice hasn’t had many releases lately, and read up on it, discovering that LibreOffice is generally updated more. Since it has iferror() support, I installed it. Now the .xlsl opens without cell errors in LibreOffice, however all of the Qty, Unit$, Ext$, and totals are zero dollars. If I re-enter the Board Qty, all values populate. Weird.

KiCost works with local (customized) libs only, where one has added manf and manf# fields to each and every symbol…
That’s why we’re having this discussion going on here:

You might also be interested in this:

EDIT:
looking at my xlsx file after not having those fields they did show $0.00 and not NAME?.. so my answer might be wrong/unrelated.

Fantastic stuff Joan! Almost a year ago I suggested a metadata manager feature. Between that and KiCost, these should save loads of time and frustration. :smile:

Very well done! Very nice tool. I use it on a Windows platform and the things I have learned are:

  • pip is the name of the tool used on a windows platform to get python packages. And that they are stored in a subdir of WinPython/…/Scripts. That is where the KiCost.exe is found in the end.
  • I had to use that path in the windows registry to associate a xml file to KiCost script (if you want to do that too)
  • When WinPython is installed, you must expand the path environment variable by yourself. Same for pip (which automatically comes with WinPython). The installer does not do that out of the box.

Good luck!

Peter

1 Like

Dear devbisme, I spent the last day trying to install KiCost, which now it seems essential to me.
I have read averything how to install it yet I got error message. Do you have tipp for me maybe?
What I did so far:

  • Installed python (2.7, 3.5 also the link you provided (Download the WinPython installer for Python 2.7.10 (32-bit))
  • did the second and third step as well, and the cmd window give me the following error messages regardles I use pip or easy_install --> “The command “pip” is either misspelled orcould not be found.” No matter what I do I always get this message.

It sounds like you need to add the paths to your WinPython to your PATH environment variable. Without that, Windows doesn’t know where to go to find the pip program. Look for where the pip program is stored and add that directory to your PATH.

Yes indeed it worked. Huge respect, and thank you for your help.
If you allow me I would have 2 more question.
-Can I use eur instead of dollar somehow?
-I use almost exclusively RS Comp, but there are Excel fields where next to a valid link and RS part number, there are no price, yet there are under Digikey or Farnell.

KiCost would require proper internationalization to use Euros instead of USD. I don’t have the expertise or interest to do that. I suppose you could also hack the web scrapers for each distributor to do that.

The web scraper for RS was written by someone else. I suppose the problem is that it can’t find the quantity pricing info on some of the RS web pages. The page formatting is not particularly uniform, so that’s not surprising.

Great time saver tool! Worked as soon I installed WinPython and also wxPython in Windows7.
I noticed it does not get results from Farnell when I use a manufacturer part number found @ Farnell … I get results from the rest of the distributors for the same part however. Anyone noticed that? Or it is me doing something wrong?

Hi @iahim67. Did you install by pip or easy_install using the pypi repository? (https://pypi.org/project/kicost/)
I propose you to install by the last code version on GitHub pip install -U git+https://github.com/xesscorp/KiCost.git (or replace manually the files), we have been fixed a lot of issues related with user experience and web distributors.
Soon this version will be automatically on pip.

If still not working, please open a issue in https://github.com/xesscorp/KiCost/issues

Hi @hildogjr, I installed by easy_install but I will try as you suggested and see how it works - thanks.
Do I need to unistall the KiCost version installed by easy_install first? Or just pip install -U git+https://github.com/xesscorp/KiCost.git?

No, the -U in pip install -U means upgrade. I never used easy_install. I think pip use easy_install internally and allow more (for example here, install from GitHub).

Let me know if worked. On Windows I already installed from Git, but on Python3, not in Py2.

I need to install git first … and learn how to use it :smiley:
image
Is it possible to change the files by hand? Which files do I need to replace in this case?

Yes, download the files here https://github.com/xesscorp/KiCost and replace the kicost folder on your Python directory (is exactly this that the command does).

I just did as you told me: replaced the kicost folder - nothing else.
There was a change as I noticed I had to install pycountry for kicost to work.
After installing pycountry I ran kicost but still no results from Farnell.
I expect kicost to find ERA6ARB102V at Farnell (ERA6ARB102V - SMD Chip Resistor, 1 kohm, ERA6A Series, 100 V, Metal Film, 0805) under the 1717624 ordering code.
Of course KiCost does find this resistor at Digikey, Mouser … etc. but I’m curious why Farnel does not work, as I have tried other resistors as well (or capacitors).
image