Cadquery installation on OSX

324 views
Skip to first unread message

Drew Marschner

unread,
Jan 10, 2018, 11:14:05 PM1/10/18
to CadQuery
Hello,

Would this be an appropriate place for a question about getting cadquery installed correctly on a Mac?

Thanks,
Drew

Jeremy Wright

unread,
Jan 10, 2018, 11:23:49 PM1/10/18
to CadQuery
Sure, is. Welcome to the community.

Are you having a problem with CadQuery on OSX? Are you running the FreeCAD workbench/module, or just CadQuery by itself on the command line?

Drew Marschner

unread,
Jan 11, 2018, 12:21:40 AM1/11/18
to CadQuery
Thanks! I've been using CadQuery on a separate ubuntu machine and it is pretty awesome.

So to the problem: I think it has to do with the fact that FreeCAD seems to install it's own version of Python on Mac. I have installed the FreeCAD workbench/module for CadQuery and verified that it works. However, CadQuery by itself on the command line does not work. The typical error is shown in the attached screenshot:

SystemError: dynamic module not initialized properly


After digging around I think this is the result of an inability on the part of my system's Python installation to correctly import FreeCAD's shared object files. They are in the Path that CadQuery assumes them to be in (/Applications/FreeCAD.app/Contents/lib), but I can't get them to import. I have tried altering my DYLD_LIBRARY_PATH to point to the FreeCAD lib directory but it still didn't work:


I might be missing something obvious, but I am out of ideas so I figured I would ask the community.

Thanks,
Drew
Screen Shot 2018-01-11 at 12.10.33 AM.png

Jeremy Wright

unread,
Jan 11, 2018, 9:15:44 AM1/11/18
to CadQuery
I forgot to reply all on one of the messages. Sorry.

Jeremy:
"The library loading is confusing. On Linux I think FreeCAD uses the Linux system's Python version. On Windows I think Python is embedded with FreeCAD, and it sounds like OSX is the same way.

The reason CadQuery does not work by itself is that the workbench manipulates sys.path when it loads so that Python will find the CadQuery library. See the code here from the workbench. If you adapt that code and set the path to the CadQuery library up in sys.path manually in the console, it should load. I've got to get to bed, but if you have trouble with that let me know and I'll post a code snippet tomorrow.

Alternatively, if there is a version of pip (or pip alternative) that works in OSX, you could install CadQuery that way. I'm not sure how that works outside of Linux and Windows though"

Drew:
"Hi Jeremy,

Thanks for the help! However I am still running into the same problem. I tried copying the code you linked to, and ran it using my system's python console. It came up with the same error as before when attempting to import CadQuery (SystemError: dynamic module not initialized properly). Attached is the code I ran.

I have pip installed, and I first installed CadQuery through pip. However whenever I try to import CadQuery in the python console the dynamic module error is triggered. Only when I couldn't get CadQuery to work in the python console did I try the workbench CadQuery, which does work.

I was looking at where CadQuery attempts to set sys.path (https://github.com/dcowden/cadquery/blob/master/cadquery/freecad_impl/__init__.py), and that init file does set the path on Mac to /Applications/FreeCAD.app/Contents/lib which is where all of the shared object files for FreeCAD (FreeCAD.so, etc.) are located. When I manually append that location to sys.path and try to import FreeCAD, the same error occurs. So I am fairly certain this isn't a CadQuery problem, it probably has something to do with how FreeCAD works on Macs.

If you have any ideas let me know, I appreciate the help!

Thanks,
Drew"

Jeremy Wright

unread,
Jan 11, 2018, 9:17:11 AM1/11/18
to CadQuery
So, now that we're caught back up...

What version of FreeCAD are you running? Can you try and older or newer version to see if that resolves the problem?

If changing versions doesn't work I'll see if I can borrow a Mac and work through this.

Drew Marschner

unread,
Jan 11, 2018, 9:38:49 PM1/11/18
to CadQuery
This is the FreeCAD version/info:

OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6712 (Git)
Build type: Release
Branch: releases/FreeCAD-0-16
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

I tried installing FreeCAD 0.15 (here: https://github.com/FreeCAD/FreeCAD/releases), but the same error occurs.

Thanks,
Drew

Jeremy Wright

unread,
Jan 12, 2018, 11:52:45 PM1/12/18
to CadQuery
I borrowed a Mac and fumbled around a little bit. I tried to import cadquery using the sys.path.insert method, but Python always segfaults. The Python version was 2.7.10, and I believe the MacOS version is Sierra.

Drew Marschner

unread,
Jan 15, 2018, 7:47:03 PM1/15/18
to CadQuery
Thanks for looking into it!

At this point I'll just keep using a VM, or maybe try out the Jupyter + cadquery notebook running on a separate server.

Thanks,
Drew

Jeremy Wright

unread,
Jan 15, 2018, 9:23:47 PM1/15/18
to CadQuery
I found a version of FreeCAD 0.16 that doesn't segfault for me.

I installed Python through Homebrew, ran 'pip2 install cadquery' and then ran python2 and did 'import cadquery'. That worked for me on MacOS 10.11.6, Python 2.7.14, and FreeCAD 0.16R6712. Please let me know if that combo works for you.

Drew Marschner

unread,
Jan 22, 2018, 10:24:07 PM1/22/18
to CadQuery
It worked! I installed FreeCAD 0.16R6712 and installed python through brew, and I now can import cadquery. Thank you so much for your help!

Drew

Jeremy Wright

unread,
Jan 22, 2018, 10:26:26 PM1/22/18
to CadQuery
Great! Glad to hear that worked for you.

Adam Vermeer

unread,
Jan 24, 2018, 8:10:09 AM1/24/18
to CadQuery
Glad that works for you, Drew!

Excellent work on your part too, Jeremy :)
Reply all
Reply to author
Forward
0 new messages