Using Trelis 17.0 without GUI in a Python Envrionment

Dear Reader,

Hope you are well in these tough times.

I have recently upgraded to Trelis 17.0 from Trelis 16.5.4.

Earlier with Trelis 16.5.4, it was possible to use Trelis and the Cubit library from a Python environment with the following code (a .py script file with the Trelis code was executed in the Python Environment)-

import sys sys.path.append('C:/Program Files/Trelis 16.5.4/bin/') sys.path.append('C:/Program Files/Trelis 16.5.4/bin/Lib/') import cubit cubit.init(['']) cubit.cmd...........
However, since updating to Trelis 17.0, this has stopped working. of course, the path in the code above has been edited to -

sys.path.append('C:/Program Files/Trelis 17.0/bin/') sys.path.append('C:/Program Files/Trelis 17.0/bin/Lib/')
But it still doesn’t seem to work. Could you please help? Below is the error -

import cubit File "C:/Program Files/Trelis 17.0/bin/", line 20, in <module> from cubit2 import * File "C:/Program Files/Trelis 17.0/bin/", line 21, in <module> _cubit2 = swig_import_helper() File "C:/Program Files/Trelis 17.0/bin/", line 20, in swig_import_helper return importlib.import_module('_cubit2') File "C:\Python27\lib\importlib\", line 37, in import_module __import__(name) ImportError: DLL load failed: The specified module could not be found.

Also, please note that the above code works when it is opened and executed inside the Trelis 17.0 GUI environment.

Also, I saw in a post that Trelis 17.0 now has support for both Python 2 and Python 3. Is this correct? I ask because the command -

print(sys.version) - still shows 2.7.10.

Thank you.
Besh wishes,


Could I please get a response? Maybe it will be helpful for other users as well :slight_smile:

Thank you.
Kind regards,

Hello @somsubhro,

Somehow I didn’t see your post earlier - thanks for replying to “bump” the thread. I’m not a Coreform-er, but I’ve had the same issue with importing the Cubit python library. This is seemingly not limited to Trelis, but Cubit as well.

I’ve previously brought up this issue with @randy and another core developer - I can’t remember exactly what the finding was, but I seem to recall it was maybe due to changes in Windows not working with the Python library import. I can’t recall if a fix was found, it sounded like a true fix was going to be fairly involved and may take some time. Personally, I switched to the Linux build of Trelis and use my Windows Subsystem Linux (WSL) as a work-around. Definitely would like to see this issue resolved.

Regarding your other question:

Also, I saw in a post that Trelis 17.0 now has support for both Python 2 and Python 3. Is this correct? I ask because the command -
print(sys.version) - still shows 2.7.10.

In the GUI you need to change from Python2 to Python3 like so:

Then you’ll need to restart Trelis.

Python 2:

print sys.version - 2.7.16

Python 3:

print(sys.version) - 3.7.4

1 Like

Hello @gvernon.

Thank you so much for your response. At least one problem is solved for now :slight_smile:

Thank you for the idea about the Linux workaround. It will be difficult to implement it in my situation, but it is a solution.

The annoying this is it used to work perfectly in Trelis 16.5.4. Ever since Trelis 17.0 was installed, the cubit library couldn’t be called from a Python environment anymore.

I hope people notice your attention and there’s some solution. Maybe the fact that it worked for Trelis 16.5.4 means that the workaround is fairly simple?

Best wishes,