Greetings To The CadQuery Mailing List,
I have a problem using a python relative import in a CadQuery app Rendered under CQ-editor 0.7.0.
Although I realize this is a python issue, I am appealing to the CadQuery community for help because, after extensively searching the Internet for solutions to the problem, I found no satisfactory answers posted by the general python community.
* * *
* * *
I have constructed a simple test case that recreates the python import error reported in CQ-editor:
ImportError: attempted relative import with no known parent package
* * *
* * *
Attachments related to the import problem:
Screenshot from 2026-06-08 12-54-14.png Image of CQ-editor window showing the ImportError mesage;
Screenshot from 2026-06-08 12-54-50.png Image of CQ-editor window showing CQ-editor version;
Importer.py python script doing the relative import;
Imported.py python script with function being imported;
ASP -- _test_relative_import - folders ls outputs - 20260608.txt ls listings of folder contents;
test relative import jobstream.txt manually entered shell commands setting PYTHONPATH environment variable and launching CQ-editor 0.7.0
* * *
* * *
Project Overview
I am using CadQuery and CQ-editor to design an Elevated Bicycle Expressway (bikeway) to be located in airspace above major urban arterial roadways.
Attached file Elevated Bicycle Expressway (bikeway) - 20221007.odt.pdf shows a graphic of the elevated bikeway structure, missing: concrete bike track, transparent side walls and roof.
* * *
* * *
Any assistance mailing list members could provide, in resolving the python import problem, would be greatly appreciated.
Steve Petrie
Etobicoke (Toronto), Canada
ape...@aspetrie.net
416-233-6116
Greetings To The CadQuery Mailing List,
I have developed a solution to the problem I reported.
The solution introduces a top level main.py script.
* * *
* * *
Here is a paste of the complete CQ-editor Log viewer contents (emphasis added):
...
[21:22:30] INFO: Importer.py: *** STARTING *** ...
The value of cwd is: /media/user/7f2b5286-3be6-4eff-b69f-f931cc56c6b9/home/steve/_bikeway/cq3/_test_relatve_import
The value of PYTHONPATH is: /media/user/7f2b5286-3be6-4eff-b69f-f931cc56c6b9/home/steve/_bikeway/cq3/Bikeway_py/_test_relatve_import
The value of __name__ is: folder_A.Importer
The value of __package___ is: /media/user/7f2b5286-3be6-4eff-b69f-f931cc56c6b9/home/steve/_bikeway/cq3/_test_relatve_import/
[21:22:30] INFO: imported.py: *** STARTING *** ...
[21:22:30] INFO: imported.py: *** FINISHED *** ...
[21:22:30] INFO: Importer.py: *** FINISHED *** ...
...
Both importer.py and Imported.py start and finish execution.
* * *
* * *
I include these attachments:
....
Screenshot from 2026-06-09 04-47-36.png screenshot of CQ-editor window at completion of execution;
test relative import jobstream.txt listing of command shell jobstream that exports PYTHONPATH and starts CQ-editor;
***NOTE***
Shell script file python_path.sh shown in attachment ASP -- _test_relative_import - folders ls outputs - 20260609.txt is ***NOT USED***
main.py
Importer.py
Imported.py
ASP -- _test_relative_import - folders ls outputs - 20260609.txt ls listings of folder contents;
...
* * *
* * *
Steve Petrie
Etobicoke (Toronto), Canada
-------- Original Message --------
| Subject: | [cadquery] ImportError: attempted relative import with no known parent package |
|---|---|
| Date: | 2026-06-08 14:28 |
| From: | Steve Petrie <ape...@aspetrie.net> |
| To: | CadQuery - Mailing List <cadq...@googlegroups.com> |
--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cadquery/30be63dd9b414511538f05d9b318f861%40aspetrie.net.
from folder_B.Imported import imported
Also, you can use print and log without imports in CQ-editor, you just lose the ability to set the logging level. I would stick with print if your scripts will be run outside of CQ-editor.
To view this discussion visit https://groups.google.com/d/msgid/cadquery/d1535a73a6ab7904c3fb24c8ee29203c%40aspetrie.net.