Python Forum
Day 1 - as newbie as you can get
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Day 1 - as newbie as you can get
#1
I tripped across ChatGPT being able to create python code for me, and it looks very useful. Im trying to create some patterns, using python to write a file in a gerber format (graphic format particular to PCB industry)

Ive installed Python , using the windows app... v3.12. I am a complete dummy/newbie here, just 20 mins in....

Chat GPT tells me that i need to install a module, and gives me this syntax "pip install pcb-tools"

When i run that, it seems to install the module correctly.

When i try to run the script, i get the following

C:\Users\johnd\python>python gerber.py
Traceback (most recent call last):
File "C:\Users\johnd\python\gerber.py", line 1, in <module>
from pcb import Gerber
ModuleNotFoundError: No module named 'pcb'


My script starts like this...

from pcb import Gerber
from pcb import primitives

# Create a new Gerber file
gerber = Gerber()


If i try to re-install the module, i get the following..

[inline]Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pcb-tools in c:\users\johnd\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (0.1.6)
Requirement already satisfied: cairocffi~=0.6 in c:\users\johnd\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from pcb-tools) (0.9.0)
Requirement already satisfied: cffi>=1.1.0 in c:\users\johnd\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from cairocffi~=0.6->pcb-tools) (1.16.0)
Requirement already satisfied: pycparser in c:\users\johnd\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from cffi>=1.1.0->cairocffi~=0.6->pcb-tools) (2.22)[/inline]

So it looks like my module is installed, but maybe its something to do with the path to it ?

Any help VERY GRATEFULLY received
Reply
#2
When you pip, you install from pypi. This is a link to the package you installed.

https://pypi.org/project/pcb-tools/

The page has an example of how to use the tools.
import gerber
from gerber.render import GerberCairoContext

# Read gerber and Excellon files
top_copper = gerber.read('example.GTL')
nc_drill = gerber.read('example.txt')
Don't depend on AI tools for programming, yet.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020