Kicost Command Line Error

@devbisme, I think Kicost is a great tool for open source designers and I commend your efforts in creating it. I can’t wait to use it. But I seem to be running into some issues running it. I am not extremely savvy in Linux, but I can normally get by.

I have Kicost 0.21 installed in Ubuntu 14.04 and I have python 2.7.6 installed. I ran easy_install -U kicost to ensure there wasn’t any new code that has been pushed recently to fix any problems and it claims 0.21 is the latest version of Kicost.

I ran kicost -s -i schematic.xml and got the following error printout:

lance@ubuntu:~/Desktop$ kicost -s -i MotorDriverRev5.xml 
No handlers could be found for logger "kicost"
Traceback (most recent call last):
  File "/usr/local/bin/kicost", line 9, in <module>
    load_entry_point('kicost==0.1.21', 'console_scripts', 'kicost')()
  File "/usr/local/lib/python2.7/dist-packages/kicost-0.1.21-py2.7.egg/kicost/__main__.py", line 132, in main
    num_processes=num_processes)
  File "/usr/local/lib/python2.7/dist-packages/kicost-0.1.21-py2.7.egg/kicost/kicost.py", line 124, in kicost
    id, url, part_num, price_tiers, qty_avail = scrape_part(args)
  File "/usr/local/lib/python2.7/dist-packages/kicost-0.1.21-py2.7.egg/kicost/kicost.py", line 1779, in scrape_part
    html_tree, url[d] = get_part_html_tree(part, d, distributor_dict, local_html)
  File "/usr/local/lib/python2.7/dist-packages/kicost-0.1.21-py2.7.egg/kicost/kicost.py", line 1753, in get_part_html_tree
    return get_dist_part_html_tree(dist, part.fields[key], extra_search_terms)
  File "/usr/local/lib/python2.7/dist-packages/kicost-0.1.21-py2.7.egg/kicost/kicost.py", line 1666, in get_newark_part_html_tree
    tree = BeautifulSoup(html, 'lxml')
  File "build/bdist.linux-x86_64/egg/bs4/__init__.py", line 212, in __init__
  File "build/bdist.linux-x86_64/egg/bs4/builder/_lxml.py", line 109, in prepare_markup
  File "build/bdist.linux-x86_64/egg/bs4/dammit.py", line 263, in encodings
  File "build/bdist.linux-x86_64/egg/bs4/dammit.py", line 33, in chardet_dammit
  File "/usr/lib/python2.7/dist-packages/chardet/__init__.py", line 24, in detect
    u.feed(aBuf)
  File "/usr/lib/python2.7/dist-packages/chardet/universaldetector.py", line 115, in feed
    if prober.feed(aBuf) == constants.eFoundIt:
  File "/usr/lib/python2.7/dist-packages/chardet/charsetgroupprober.py", line 59, in feed
    st = prober.feed(aBuf)
  File "/usr/lib/python2.7/dist-packages/chardet/utf8prober.py", line 52, in feed
    codingState = self._mCodingSM.next_state(c)
  File "/usr/lib/python2.7/dist-packages/chardet/codingstatemachine.py", line 43, in next_state
    byteCls = self._mModel['classTable'][ord(c)]
TypeError: ord() expected string of length 1, but int found

Any insight into what I am doing wrong here? Some of my parts don’t have manf# fields, I was just trying to test it out for a few parts to start with.

Thanks!

EDIT

I am also running Ubuntu inside a VM, I highly doubt that is an issue but figured it was worth noting.

Hi, apologies for my late reply.

It looks like it’s going astray inside the BeautifulSoup package. I’m not sure what the error messages that follow that are trying to say.

FWIW, I’m going most of my development with Python 2.7.10 and 3.4.3. You might try upgrading your Python and/or the BeautifulSoup package to see if that changes the behavior.

Sorry I’m not much more help on this.

That’s fine, I will figure it out. I am curious how you use python 2.7 as well as python 3.4. I’m assuming it is one or the other at separate times They could even be installed simultaneously one one’s machine.

Do you assume python 3.4 function calls are made as python and not python3 ?

It is possible my BOM has some formatting issue that breaks your script, do you have an example xml file that you know works for your script?

Thanks!

I’m on Windows 7. I have Python 2 and 3 in different directories. I have a script that changes the PATH variable to put one or the other in the path. Primitive but effective. All my calls are to python, never to python3. The kicost script runs with either python 2 or 3.

I doubt your xml file is the problem. I attached an XML file for you to try.

test.xml (28.8 KB)

My options for operating systems are windows 10 or linux. Have you ever run kicost in linux?

I also doubt it is my XML file as well. I will try installing the 32bit version of WinPython you describe in this post. It will be on Windows 10, but worth a shot.

Update to come after I get home from work tonight.

I got it up in running in windows 10, I had to run a serial process using -s however.

This is a pretty neat tool! It looks like you only pull in the qty 1 pricing from the distributor sites, is this correct?

I retract that statement, I missed the lookup vector in the pricing cell. This is going to be a very useful tool for me my friend. Nice work!

Glad it’s working for you!

I’ve had problems getting the multiprocessing working with Python 2. Python 3 may solve this problem for you.

I will give python3 a whirl.