← Back to team overview

kicad-developers team mailing list archive

Re: Opening pcbnew from kicad: ImportError: No module named pcbnew

 

Hi!

>>> It gets more interesting when I add the path to pcbnew.py:
>>>
>>> $ PYTHONPATH=~/SW/lib/python2.7/site-packages ./pcbnew
>>
>> I believe you wanted to do:
>>
>> $ export PYTHONPATH=~/SW/lib/python2.7/site-packages ./pcbnew
> 
> You don't need the export when you write the variable before the
> command like this. But I am unsure if the tilde behaves as you expect
> here. One could try to use ${HOME} or actually write /home/username
> instead of the tilde.

Python internally resolves the ~/... properly to /home/<username>/...
and puts it in the front of the search path:

$ PYTHONPATH=~/SW/lib/python2.7/site-packages python
Python 3.5.1 (default, Dec  7 2015, 12:58:09) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/home/admin/SW/lib/python2.7/site-packages', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-linux', '/usr/lib/python3.5/lib-dynload', '/usr/lib/python3.5/site-packages']


>>> Traceback (most recent call last):
>>>   File "<string>", line 3, in <module>
>>>   File "/home/admin/SW/lib/python2.7/site-packages/pcbnew.py", line 5055, in <module>
>>>     class BOARD(BOARD_ITEM):
>>>   File "/home/admin/SW/lib/python2.7/site-packages/pcbnew.py", line 5710, in BOARD
>>>     def GetViaByPosition(self, aPosition, aLayer=UNDEFINED_LAYER):
>>> NameError: name 'UNDEFINED_LAYER' is not defined
>>>
>>> I am not into the python internals, but it seems something smells down that road.
>>> We can just declare installing kicad with python support as non-root currently
>>> as "unsupported". I am fine with that for now.
>>
>> At least you resolved you module load issue so that's a step in the
>> right direction.  I don't know how thoroughly the Python module code has
>> been tested so you may find some issues here and there.

If somebody wants me to debug something in this area, let me know.
Otherwise, I'll stop digging at this place and call it a day.

Regards,

Clemens


Follow ups

References