it works with python2 but if I do the same thing with python3 I get an error:
Traceback (most recent call last):
File “myscript.py”, line 16, in
import cubit
File “/Applications/Coreform-Cubit-2021.3.app/Contents/MacOS/cubit.py”, line 29, in
from cubit3 import *
File “/Applications/Coreform-Cubit-2021.3.app/Contents/MacOS/cubit3.py”, line 15, in
import _cubit3
ImportError: dlopen(/Applications/Coreform-Cubit-2021.3.app/Contents/MacOS/_cubit3.so, 2): Symbol not found: _PyCMethod_New
Referenced from: /Applications/Coreform-Cubit-2021.3.app/Contents/MacOS/_cubit3.so
Expected in: flat namespace
in /Applications/Coreform-Cubit-2021.3.app/Contents/MacOS/_cubit3.so
Hi @balep, sorry for your trouble. First off, we use Python 3.9.2 on Mac, so loading Cubit into 3.8.5 is unlikely to work. Secondly, in 2021.3 there were still some Mac-specific bugs in how we packaged Python 3.9.2 that have been fixed in 2021.5. I’d recommend you do two things:
Upgrade to 2021.5 from our downloads page.
Either use Python 3.9.2 or use the version of Python that ships with Cubit. On Mac, it’s at this path:
Thanks for asking this @balep. Another workaround I had for this was to install a conda environment with Python 3.9.2. Once the environment was activated, at the top of my Python script I include: