CQ CLI finding modules

120 views
Skip to first unread message

Walt Z

unread,
Feb 10, 2022, 4:49:36 PM2/10/22
to CadQuery
I've got CQ-Editor working with my model and it works great.  I'm now trying to use CQ-CLI to generate an STL file and it doesn't find my modules other than the main one.  Here's the start of my main module:

import cadquery as cq
from cadquery import exporters
import sys

def delModule(name):
if name in sys.modules:
del sys.modules[name]

delModule("common")
import common as c

Here's the error message:
ModuleNotFoundError: No module named 'common'

common.py is in the same folder as my main python file.

How can I make cq-cli see my other modules?

Jeremy Wright

unread,
Feb 10, 2022, 5:02:49 PM2/10/22
to CadQuery
Try setting the PYTHONPATH environment variable to the directory containing common.py when starting cq-cli.

Jeremy Wright

unread,
Feb 10, 2022, 5:33:17 PM2/10/22
to CadQuery
Does your main CadQuery script use relative imports in it?

--
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 a topic in the Google Groups "CadQuery" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cadquery/ovX86CfS12w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/4b3fa538-b479-4d6d-a8e5-7360454da2efn%40googlegroups.com.

Walt Z

unread,
Feb 10, 2022, 8:25:31 PM2/10/22
to CadQuery
Hmm....

Does cq-cli use CadQuery 1.0?

It looks like the "bool not subscriptable" error comes from passing "centered=False" to box().  In CQ 1.0, centered needs a 3-tuple.

Any way I can get it using CQ2?

Jeremy Wright

unread,
Feb 11, 2022, 6:17:13 AM2/11/22
to CadQuery
cq-cli does not support CQ 1.x, only CQ 2.x.

CQ 2.x was changed to accept both a bool and a 3 tuple. Are you running an older release of cq-cli from before that change was made? You could try one of the newer development builds. https://github.com/CadQuery/cq-cli/actions/workflows/pyinstaller-builds-actions.yml

Otherwise, please post some sample code.

Walt Z

unread,
Feb 11, 2022, 6:40:22 AM2/11/22
to CadQuery
I installed CQ CLI Release for CadQuery 2.1 from here: https://github.com/CadQuery/cq-cli/releases

It fails on even the simplest CQ2 app (below).  I'm thinking I have both CQ1 and CQ2 installed, but I don't know enough about Python to know where to look for it.   I did find CQ 1.2.5 using pip and I removed that, but it seems I still have CQ1 somewhere.

import cadquery as cq
result = cq.Workplane("XY").box(10, 20, 30, centered=False)

Walt Z

unread,
Feb 11, 2022, 10:02:33 AM2/11/22
to CadQuery
Getting closer!   I added a "print(cq.__file__) to my simple app and it tells me this:

/home/walt/nextcloud/Documents/Apps/cq-cli/cadquery/__init__.pyc

Walt Z

unread,
Feb 11, 2022, 10:06:56 AM2/11/22
to CadQuery
But then again...

I looked in /home/walt/Documents/Apps/cq-cli, and there is no cadquery folder.  So I went into Nautilus and searched my entire machine for "cadquery", and I can account for every instance.  I don't see anything that could be a cadquery library or folder.

Walt Z

unread,
Feb 11, 2022, 10:44:49 AM2/11/22
to CadQuery
Just a note:

my Documents folder is a link to my nextcloud/Documents folder, so
/home/walt/Documents and
/home/walt/nextcloud/Documents are the same folder.

Jeremy Wright

unread,
Feb 18, 2022, 8:23:22 AM2/18/22
to CadQuery
I am not able to reproduce this issue of cq-cli not being able to see other modules in the same directory. I created two files, box1.py and box2.py

box1.py:
> import cadquery as cq
> from box2 import make_box
>
> box1 = cq.Workplane().box(10, 10, 10)
> box2 = make_box()
>
> boxes = box1.union(box2)
>
> show_object(boxes)

box2.py
> import cadquery as cq
>
> def make_box():
>     result = cq.Workplane().box(10, 10, 10).translate((5, 5, 5))
>     return result

I then ran the following cq-cli command line and got proper looking STL output:
> ./cq-cli --codec stl --infile /path/to/box_example/box1.py

On Thursday, February 10, 2022 at 4:49:36 PM UTC-5 walt...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages