![]() |
Day 1 - as newbie as you can get - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Day 1 - as newbie as you can get (/thread-42377.html) |
Day 1 - as newbie as you can get - boss_hogg - Jun-27-2024 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 RE: Day 1 - as newbie as you can get - deanhystad - Jun-28-2024 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. RE: Day 1 - as newbie as you can get - AdamHensley - Jul-01-2024 It looks like you're having trouble importing the pcb-tools module in your Python script. The issue might be that the module is named differently than what you're trying to import. From your error message and the package name, it seems like you should be importing from gerber instead of pcb. Try changing your script to this: from gerber import Gerber from gerber import primitives # Create a new Gerber file gerber = Gerber() If this still doesn't work, it might be helpful to check the documentation or the source code of the pcb-tools module to verify the correct import statements. Also, make sure your script file is not named gerber.py as it could conflict with the module name. |