Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansys.mechanical.core.App() raises SEH Exception #918

Open
2 tasks done
62Scorch opened this issue Sep 25, 2024 · 10 comments
Open
2 tasks done

ansys.mechanical.core.App() raises SEH Exception #918

62Scorch opened this issue Sep 25, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@62Scorch
Copy link

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

Hi all,

I'm trying to start a PyMechanical Embedded application but during the initialisation of the app it crashes and reports an SEH Exception.

Troubleshooting I have tried so far:

  1. Running Ansys Remote instead (which was successfull)
  2. Calling App() with and without a db file specified
  3. Restarting the Kernel, Note: when I don't restart this different errors are produced

There is some reason to believe that this may also be an interaction with the licence server, because the person who managed that did say that around the time I was trying this he also had some issues there. However the timepaths are a bit unclear so it could be a coincidence, or something that was caused by the exception.

Thanks in advance for your help!

Issue was originally posted on te Ansys Dev form but they referred me here https://discuss.ansys.com/discussion/4433/pymechanical-embedded-seh-exception-during-start-application#latest)

I hope this is the right place, please let me know if you have any further feedback or require more info!

📝 Steps to reproduce

Start Python in the Spyder IDE and run the following code:

import logging
import ansys.mechanical.core as mech
from ansys.mechanical.core.embedding.logger import Configuration, Logger
# app = mech.App(version = 241) 
 
from ansys.tools.path import find_mechanical 
Configuration.configure(
    level=logging.DEBUG,  # Set the desired logging level
    directory="C:\\Users\\k.XXXXX\\Desktop\\log_files",  # Directory to save the log files
    to_stdout=True  # Output logs to standard output
)
find_mechanical(version = 241)  #This steps is successfull
embedded = mech.App(version = 241, db_file="C:\\Users\\k.XXXXX\\Desktop\\export_mechanical.mechdat")

This outputs the following result:

%runfile C:/Users/k.XXXXX/Desktop/ProTube_Python_Testing_Env2/starting_embedded.py --wdir
2024-09-17 15:14:32.874315 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : Checking debug stop
2024-09-17 15:14:32.874315 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : Setting environment
2024-09-17 15:14:32.875414 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : using aisolPath C:\Program Files\ANSYS Inc\v241\aisol\bin\winx64
2024-09-17 15:14:32.893249 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : running wb config
2024-09-17 15:14:32.895278 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : running AnsCoInitialize
2024-09-17 15:14:33.005950 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : ran AnsCoInitialize, result: 1
2024-09-17 15:14:33.006954 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : ran AnsSetRegistryLoadConfiguration, result: 0
2024-09-17 15:14:33.013821 (Thread 0x000018a0) [WORKBENCH, info] --------------- : ************ Workbench 1 - version: 241 build: 20231127 ************
2024-09-17 15:14:33.014902 (Thread 0x000018a0) [WORKBENCH, info] ----- ScopeBegin: CWB::FinalConstruct
2024-09-17 15:14:33.016005 (Thread 0x000018a0) [WORKBENCH, trace] -------------- : ActiveWBMgrObject creation succeeded
2024-09-17 15:14:33.016005 (Thread 0x000018a0) [WORKBENCH, trace] -------------- : WBCommandLine creation succeeded
2024-09-17 15:14:33.016005 (Thread 0x000018a0) [WORKBENCH, trace] -------------- : WBSplashScreen creation succeeded
2024-09-17 15:14:33.022848 (Thread 0x000018a0) [WORKBENCH, info] ----- ScopeEnd  : CWB::FinalConstruct <8 ms>
Traceback (most recent call last):
 
  File ~\Desktop\XXXX_Python_Testing_Env2\.env\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
    exec_fun(compile(code_ast, filename, "exec"), globals)
 
  File c:\users\k.XXXXX\desktop\XXXX_python_testing_env2\starting_embedded.py:19
    embedded = mech.App(version = 241, db_file="C:\\Users\\k.XXXXX\\Desktop\\export_mechanical.mechdat")
 
  File ~\Desktop\XXXX_Python_Testing_Env2\.env\Lib\site-packages\ansys\mechanical\core\embedding\app.py:141 in __init__
    self._app = _start_application(configuration, self._version, db_file)
 
  File ~\Desktop\XXXX_Python_Testing_Env2\.env\Lib\site-packages\ansys\mechanical\core\embedding\app.py:78 in _start_application
    return Ansys.Mechanical.Embedding.Application(db_file, addin_configuration_name)
 
SEHException:  (0x80004005): Eine externe Komponente hat eine Ausnahme ausgelöst.!

"Eine externe Komponente hat eine Ausnahme ausgelöst.!" translates to: "An external component has raised an Exception.!"

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

Ansys Version 2024R1

Operating System: Windows 11 via remote Desktop (running as a VM on a linux server)
Ansys Version: 2024R1
Licenses Available Via Licence Server
License Types: Floating, and Elastic (I can list the exact names of the licences on request)
Python Version: 3.11
IDE: Spyder 6.0.0 (installed via pip)

🐍 Which Python version are you using?

3.11

📦 Installed packages

aiohappyeyeballs==2.4.0
aiohttp==3.10.5
aiosignal==1.3.1
alabaster==1.0.0
ansys-api-mechanical==0.1.2
ansys-api-platform-instancemanagement==1.1.0
ansys-api-workbench==0.2.0
ansys-mechanical-core==0.11.7
ansys-mechanical-env==0.1.7
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc3
ansys-tools-path==0.6.0
ansys-workbench-core==0.6.0
appdirs==1.4.4
arrow==1.3.0
astroid==3.2.4
asttokens==2.4.1
asyncssh==2.17.0
atomicwrites==1.4.1
attrs==24.2.0
autopep8==2.0.4
babel==2.16.0
backports.tarfile==1.2.0
beautifulsoup4==4.12.3
binaryornot==0.4.4
black==24.8.0
bleach==6.1.0
certifi==2024.8.30
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
cloudpickle==3.0.0
clr-loader==0.2.6
colorama==0.4.6
comm==0.2.2
contourpy==1.3.0
cookiecutter==2.6.0
cryptography==43.0.1
cycler==0.12.1
debugpy==1.8.5
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.14
diff-match-patch==20230430
dill==0.3.8
docstring-to-markdown==0.15
docutils==0.21.2
executing==2.1.0
fastjsonschema==2.20.0
flake8==7.1.1
fonttools==4.53.1
frozenlist==1.4.1
grpcio==1.66.1
idna==3.10
imagesize==1.4.1
importlib_metadata==8.5.0
inflection==0.5.1
intervaltree==3.1.0
ipykernel==6.29.5
ipython==8.27.0
isort==5.13.2
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.0.2
jedi==0.19.1
jellyfish==1.1.0
Jinja2==3.1.4
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
jupyter_client==8.6.2
jupyter_core==5.7.2
jupyterlab_pygments==0.3.0
keyring==25.3.0
kiwisolver==1.4.7
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.9.2
matplotlib-inline==0.1.7
mccabe==0.7.0
mdurl==0.1.2
mistune==3.0.2
more-itertools==10.5.0
multidict==6.1.0
mypy-extensions==1.0.0
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
numpy==2.1.1
numpydoc==1.8.0
packaging==24.1
pandas==2.2.2
pandocfilters==1.5.1
parso==0.8.4
pathspec==0.12.1
pexpect==4.9.0
pickleshare==0.7.5
pillow==10.4.0
platformdirs==4.3.3
pluggy==1.5.0
prompt_toolkit==3.0.47
protobuf==5.28.1
psutil==6.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycodestyle==2.12.1
pycparser==2.22
pydocstyle==6.3.0
pyflakes==3.2.0
PyGithub==2.4.0
Pygments==2.18.0
PyJWT==2.9.0
pylint==3.2.7
pylint-venv==3.0.3
pyls-spyder==0.4.0
PyNaCl==1.5.0
pyparsing==3.1.4
PyQt5==5.15.11
PyQt5-Qt5==5.15.2
PyQt5_sip==12.15.0
PyQtWebEngine==5.15.7
PyQtWebEngine-Qt5==5.15.2
python-dateutil==2.9.0.post0
python-lsp-black==2.0.0
python-lsp-jsonrpc==1.1.2
python-lsp-server==1.12.0
python-slugify==8.0.4
pytoolconfig==1.3.1
pytz==2024.2
pyuca==1.2
pywin32==306
pywin32-ctypes==0.2.3
PyYAML==6.0.2
pyzmq==26.2.0
QDarkStyle==3.2.3
qstylizer==0.2.3
QtAwesome==1.3.1
qtconsole==5.6.0
QtPy==2.4.1
referencing==0.35.1
requests==2.32.3
rich==13.8.1
rope==1.13.0
rpds-py==0.20.0
Rtree==1.3.0
six==1.16.0
snowballstemmer==2.2.0
sortedcontainers==2.4.0
soupsieve==2.6
Sphinx==8.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
spyder==6.0.0
spyder-kernels==3.0.0
stack-data==0.6.3
superqt==0.6.7
tabulate==0.9.0
text-unidecode==1.3
textdistance==4.6.3
three-merge==0.1.1
tinycss2==1.3.0
tomli==2.0.1
tomlkit==0.13.2
tornado==6.4.1
tqdm==4.66.5
traitlets==5.14.3
types-python-dateutil==2.9.0.20240906
typing_extensions==4.12.2
tzdata==2024.1
ujson==5.10.0
urllib3==2.2.3
watchdog==5.0.2
wcwidth==0.2.13
webencodings==0.5.1
whatthepatch==1.0.6
WMI==1.5.1
wrapt==1.16.0
yapf==0.40.2
yarl==1.11.1
zipp==3.20.2
@62Scorch 62Scorch added the bug Something isn't working label Sep 25, 2024
@dipinknair
Copy link
Collaborator

@62Scorch Thanks for opening this issue. Could you please try this in a virtual environment where only ansys-mechanical-core is installed and see? If possible, please attach the log also.

@62Scorch
Copy link
Author

62Scorch commented Oct 2, 2024

@dipinknair Thanks for your response. I will test this as soon as possible, but I don't have access to the licence right now. So it will probably be towards the end of this week.

@62Scorch
Copy link
Author

62Scorch commented Oct 3, 2024

I ran the file with the following environment, running python through command prompt

(embedded_test) C:\>pip freeze
ansys-api-mechanical==0.1.2
ansys-api-platform-instancemanagement==1.1.0
ansys-mechanical-core==0.11.7
ansys-mechanical-env==0.1.7
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc3
ansys-tools-path==0.6.0
appdirs==1.4.4
cffi==1.17.1
click==8.1.7
clr-loader==0.2.6
colorama==0.4.6
grpcio==1.66.2
importlib_metadata==8.5.0
platformdirs==4.3.6
protobuf==5.28.2
pycparser==2.22
tqdm==4.66.5
zipp==3.20.2

(These were all the libraries that were added after running pip install ansys-mechanical-core in the base environment)

Which gave the following result (the same as in the other environment)

C:\>C:\Users\k.XXXXX\Desktop\embedded_test\Scripts\activate.bat

(embedded_test) C:\>python
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> import ansys.mechanical.core as mech
>>> from ansys.mechanical.core.embedding.logger import Configuration, Logger
>>> # app = mech.App(version = 241)
>>>
>>> from ansys.tools.path import find_mechanical
>>> Configuration.configure(
...     level=logging.DEBUG,  # Set the desired logging level
...     directory="C:\\Users\\k.XXXXX\\Desktop\\log_files",  # Directory to save the log files
...     to_stdout=True  # Output logs to standard output
... )
>>> find_mechanical(version = 241)
('C:\\Program Files\\ANSYS Inc\\v241\\aisol\\bin\\winx64\\AnsysWBU.exe', 24.1)
>>> embedded = mech.App(version = 241)
2024-10-03 09:20:17.810580 (Thread 0x00002a10) [EmbeddedMechanical, trace] ----- : Checking debug stop
2024-10-03 09:20:17.811610 (Thread 0x00002a10) [EmbeddedMechanical, trace] ----- : Setting environment
2024-10-03 09:20:17.812705 (Thread 0x00002a10) [EmbeddedMechanical, trace] ----- : using aisolPath C:\Program Files\ANSYS Inc\v241\aisol\bin\winx64
2024-10-03 09:20:17.831446 (Thread 0x00002a10) [EmbeddedMechanical, trace] ----- : running wb config
2024-10-03 09:20:17.855786 (Thread 0x00002a10) [EmbeddedMechanical, trace] ----- : running AnsCoInitialize
2024-10-03 09:20:17.965435 (Thread 0x00002a10) [EmbeddedMechanical, trace] ----- : ran AnsCoInitialize, result: 1
2024-10-03 09:20:17.966505 (Thread 0x00002a10) [EmbeddedMechanical, trace] ----- : ran AnsSetRegistryLoadConfiguration, result: 0
2024-10-03 09:20:17.974390 (Thread 0x00002a10) [WORKBENCH, info] --------------- : ************ Workbench 1 - version: 241 build: 20231127 ************
2024-10-03 09:20:17.975479 (Thread 0x00002a10) [WORKBENCH, info] ----- ScopeBegin: CWB::FinalConstruct
2024-10-03 09:20:17.977022 (Thread 0x00002a10) [WORKBENCH, trace] -------------- : ActiveWBMgrObject creation succeeded
2024-10-03 09:20:17.977022 (Thread 0x00002a10) [WORKBENCH, trace] -------------- : WBCommandLine creation succeeded
2024-10-03 09:20:17.977022 (Thread 0x00002a10) [WORKBENCH, trace] -------------- : WBSplashScreen creation succeeded
2024-10-03 09:20:17.980158 (Thread 0x00002a10) [WORKBENCH, info] ----- ScopeEnd  : CWB::FinalConstruct <4 ms>
CRITICAL -  -  logging - handle_exception - Uncaught exception
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\k.XXXXX\Desktop\embedded_test\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 141, in __init__
    self._app = _start_application(configuration, self._version, db_file)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\k.XXXXX\Desktop\embedded_test\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 78, in _start_application
    return Ansys.Mechanical.Embedding.Application(db_file, addin_configuration_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
System.Runtime.InteropServices.SEHException:  (0x80004005): Eine externe Komponente hat eine Ausnahme ausgelöst.

The logfile contents are the same as the printed info in the kernel above

@dipinknair
Copy link
Collaborator

@62Scorch Thanks for checking this. I tested with VM and could not reproduce this issue. Could you please try without spyder?
you don't need access to license for checking the creation of app if you are not loading any mechdat/mechdb. You can try without loading db.

@62Scorch
Copy link
Author

62Scorch commented Oct 7, 2024

@dipinknair The last run I sent you was without the mechdat/mechdb, and without spyder (I simply ran it from the command prompt)

Is there maybe some relevant information about my specific set-up that is required to recreate the issue?
Are there any things you could think of that could be relevant information?

@koubaa
Copy link
Collaborator

koubaa commented Oct 24, 2024

@62Scorch I apologize for the delay! Please try running the following and let me know what output you see:

import os
import ansys.mechanical.core as mech
from ansys.mechanical.core.embedding.utils import load_library_windows
from ansys.mechanical.core.embedding.initializer import initialize
version = 241
initialize(version)
libname = "AnsXML.dll"
lib = os.path.join(os.environ[f"AWP_ROOT{version}"], "aisol", "bin", "winx64", libname)
load_library_windows(lib)

@tymanSTG
Copy link

Is there any updates on this? I am running into the same issue. I recently had a clean windows install on my machine. Since this I am receiving the same errors when I try to run a pymechanical script. I tried running the commands in the comment above but this did not resolve the issue.

`>>> app = mech.App(version = 242)
CRITICAL - - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "", line 1, in
File "c:\Users\tduvall\Desktop\envs\python311\mech_only\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 149, in init
self._app = _start_application(configuration, self._version, db_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\tduvall\Desktop\envs\python311\mech_only\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 85, in _start_application
if int(version) >= 241:
^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

app = mech.App(version = "242")
CRITICAL - - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "", line 1, in
File "c:\Users\tduvall\Desktop\envs\python311\mech_only\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 140, in init
self._version = initializer.initialize(version)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\tduvall\Desktop\envs\python311\mech_only\Lib\site-packages\ansys\mechanical\core\embedding\initializer.py", line 171, in initialize
raise ValueError(
ValueError: Initialized version 242 does not match the expected version 242.
app = mech.App()
CRITICAL - - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "", line 1, in
File "c:\Users\tduvall\Desktop\envs\python311\mech_only\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 140, in init
self._version = initializer.initialize(version)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\tduvall\Desktop\envs\python311\mech_only\Lib\site-packages\ansys\mechanical\core\embedding\initializer.py", line 171, in initialize
raise ValueError(
ValueError: Initialized version 242 does not match the expected version None.`

@koubaa
Copy link
Collaborator

koubaa commented Nov 12, 2024

@tymanSTG that looks like a different issue than the reported one. @dipinknair could you please support?

@dipinknair
Copy link
Collaborator

@tymanSTG for the recent issue you are facing, please use int type argument when staring app.

- app = mech.App(version = "242")
+ app = mech.App(version = 242)

In addition to this please update to latest pymechanical using pip install ansys-mechanical-core --upgrade
To check if path to installed version is reachable, can you try this as well from your virtual env and reply here?

find-mechanical -r 242

@koubaa
Copy link
Collaborator

koubaa commented Nov 13, 2024

@dipinknair There's an opportunity to improve our code here. Let's make a change so that we either convert the string to an int or error immediately if the type isn't an int

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants