snhobbs / kicad-parts-placer

Auto place components into pcbnew from a centroid file. Useful for maintaining a common board form factor.
GNU Lesser General Public License v3.0
24 stars 1 forks source link

ERROR: unknown command "kicad-parts-placer" ? #7

Closed MA812 closed 4 months ago

MA812 commented 4 months ago

Description

When I try to use this KiCad part placer, I got 'unknown error' but before, script say me 'installed'... I try both pip and pip3

What I Did

pip kicad-parts-placer --pcb example-placement.kicad_pcb --config centroid-all-pos.csv --out example-placement_placed.kicad_pcb -x 117.5 -y 53

more info on picture Capture d'écran du 2024-07-31 05 25 38

snhobbs commented 4 months ago

pip is an installer. Once the package is installed the tool should be available on your path. You can search for it by using the 'whereis' tool. Try 'whereis kicad_parts_placer'. Then try just dropping pip.

MA812 commented 4 months ago

Hello, This works.

Now, I got an error pcbnew not found... aa@aaa:~/Téléchargements/kicad-parts-placer/example/example-placement$ sudo /home/aa/.local/bin/kicad_parts_placer --pcb example-placement.kicad_pcb --config centroid-all-pos.csv --out example-placement_placed.kicad_pcb -x 117.5 -y 53 /usr/local/lib/python3.8/dist-packages/pandas/core/computation/expressions.py:20: UserWarning: Pandas requires version '2.7.3' or newer of 'numexpr' (version '2.7.1' currently installed). from pandas.core.computation.check import NUMEXPR_INSTALLED Traceback (most recent call last): File "/home/aa/.local/bin/kicad_parts_placer", line 5, in <module> from kicad_parts_placer.cli import main File "/usr/local/lib/python3.8/dist-packages/kicad_parts_placer/__init__.py", line 6, in <module> from .kicad_parts_placer import * File "/usr/local/lib/python3.8/dist-packages/kicad_parts_placer/kicad_parts_placer.py", line 5, in <module> import pcbnew ModuleNotFoundError: No module named 'pcbnew'

So I did $ sudo apt install --install-recommends kicad And its ok.

I got new error (TypeError: unsupported operand type(s) for |: 'type' and 'NoneType') aa@aaa:~/Téléchargements/kicad-parts-placer/example/example-placement$ /home/aa/.local/bin/kicad_parts_placer --pcb example-placement.kicad_pcb --config centroid-all-pos.csv --out example-placement_placed.kicad_pcb -x 117.5 -y 53 /home/aa/.local/lib/python3.8/site-packages/pandas/core/computation/expressions.py:20: UserWarning: Pandas requires version '2.7.3' or newer of 'numexpr' (version '2.7.1' currently installed). from pandas.core.computation.check import NUMEXPR_INSTALLED Traceback (most recent call last): File "/home/aa/.local/bin/kicad_parts_placer", line 5, in <module> from kicad_parts_placer.cli import main File "/home/aa/.local/lib/python3.8/site-packages/kicad_parts_placer/__init__.py", line 6, in <module> from .kicad_parts_placer import * File "/home/aa/.local/lib/python3.8/site-packages/kicad_parts_placer/kicad_parts_placer.py", line 115, in <module> group_name: str | None = None, TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' So, how can I fix it up ?

snhobbs commented 4 months ago

So the pcbnew.so library does need to be on your python path. The usual way of doing this is compiling from source and seeing the PYTHONPATH variable. Alternatively you can use the plug-in which can be downloaded and installed all within KICAD using the plug-in content manager (it's one of the icons in the project view). That works out of the box without any configuration.

snhobbs commented 4 months ago

Sorry I skimmed and missed that you got pcbnew installed. The syntax issue is due to typing syntax changes so you need python 3.10+