Closed zueskalare closed 5 months ago
@zueskalare Could you please give more information?
@zueskalare Could you please give more information?
- Were you using pymechanical remote or embedding?
- What is the Linux distribution?
- Can you provide where exactly are you getting this error ?
I was using jupyter, and choose the a clean env and install only matplotlib & pyansys using pip install -U here is the code
import os
import ansys.mechanical.core as mech
from ansys.mechanical.core import launch_mechanical
from ansys.mechanical.core.examples import delete_downloads, download_file
from matplotlib import image as mpimg
from matplotlib import pyplot as plt
from ansys.mechanical.core import App
os.environ['AWP_ROOT232'] = '/apps/ANSYS/ansys_inc/v232'
app = mech.App(version=232) # here happens the error
Here is all the error
{
"name": "DllNotFoundException",
"message": "Ans.Common.WBLogger.dll assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Ansys.Common.WB1ManagedUtils.Logger+Imports.wb_logger_log_message(int,string,string)
at Ansys.Common.WB1ManagedUtils.Logger.LogMessage (Ansys.Common.WB1ManagedUtils.Logger+LoggerSeverity severity, System.String context, System.String message) [0x00000] in <eff273037c1b4021aa0bb7b554088b82>:0
at Ansys.Mechanical.Embedding.Application.trace (System.String msg) [0x00000] in <453e70f297334f5db0d8841fbf1f0dac>:0
at Ansys.Mechanical.Embedding.Application.startApp (System.String dbFile) [0x00000] in <453e70f297334f5db0d8841fbf1f0dac>:0
at Ansys.Mechanical.Embedding.Application..ctor (System.String dbFile) [0x00006] in <453e70f297334f5db0d8841fbf1f0dac>:0
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <e85874d36dd54c51a7dcd93d72f2c404>:0 ",
"stack": "---------------------------------------------------------------------------
DllNotFoundException Traceback (most recent call last)
Cell In[3], line 1
----> 1 app = mech.App(version=232)
2 globals().update(mech.global_variables(app, True))
3 print(app)
File ~/.conda/envs/ansys/lib/python3.10/site-packages/ansys/mechanical/core/embedding/app.py:128, in App.__init__(self, db_file, private_appdata, **kwargs)
125 profile.update_environment(os.environ)
126 atexit.register(_cleanup_private_appdata, profile)
--> 128 self._app = _start_application(configuration, self._version, db_file)
129 runtime.initialize(self._version)
130 connect_warnings(self)
File ~/.conda/envs/ansys/lib/python3.10/site-packages/ansys/mechanical/core/embedding/app.py:67, in _start_application(configuration, version, db_file)
65 return Ansys.Mechanical.Embedding.Application(db_file, addin_configuration_name)
66 else:
---> 67 return Ansys.Mechanical.Embedding.Application(db_file)
DllNotFoundException: Ans.Common.WBLogger.dll assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Ansys.Common.WB1ManagedUtils.Logger+Imports.wb_logger_log_message(int,string,string)
at Ansys.Common.WB1ManagedUtils.Logger.LogMessage (Ansys.Common.WB1ManagedUtils.Logger+LoggerSeverity severity, System.String context, System.String message) [0x00000] in <eff273037c1b4021aa0bb7b554088b82>:0
at Ansys.Mechanical.Embedding.Application.trace (System.String msg) [0x00000] in <453e70f297334f5db0d8841fbf1f0dac>:0
at Ansys.Mechanical.Embedding.Application.startApp (System.String dbFile) [0x00000] in <453e70f297334f5db0d8841fbf1f0dac>:0
at Ansys.Mechanical.Embedding.Application..ctor (System.String dbFile) [0x00006] in <453e70f297334f5db0d8841fbf1f0dac>:0
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <e85874d36dd54c51a7dcd93d72f2c404>:0 "
}
**the linux distribution : It's a machine instance by submitting a slurm job
uname -a
>>> Linux a2-4 4.18.0-477.15.1.el8_8.x86_64 #1 SMP Wed Jun 28 15:04:18 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
@zueskalare mechanical-env
has to be called before we start python. Jupyter notebook starts python kernel using kernel.json
{ "argv": [ "python", "-m", "ipykernel_launcher", "-f", "{connection_file}" ], "display_name": "Python 3 (ipykernel)", "language": "python", "metadata": { "debugger": true } }
which needs to be modified if you have to work pymechanical embedding with jupyter in Linux.
steps :
pip install ansys-mechanical-core
)jupyter kernelspec list
)
python3 /user/username/pymechanical/.venv/share/jupyter/kernels/python3
(this directory is just an example)mechanical-env
in the begining
{
"argv": [
"mechanical-env",
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3 (ipykernel)",
"language": "python",
"metadata": {
"debugger": true
}
jupyter kernelspec install /user/username/pymechanical/.venv/share/jupyter/kernels/python3/ --user
(use respective kernel path in you venv)Use same kernel you modified when using jupyter.
Let me know if this helps.
@zueskalare if this solves the issue, the please close the issue or else provide more information.
@dipinknair Sorry for not replying in time. I don't know wheter i set the Jupyter correctly, so i create a new cond venv and choose not to use vscode here is the history
26 [2024-04-17 14:55:58] conda create py_mech
27 [2024-04-17 14:56:13] conda create -n py_mech python==3.11
28 [2024-04-17 14:57:26] conda activate py_mech
32 [2024-04-17 14:58:49] pip install -U ansys-mechanical-core
34 [2024-04-17 14:59:12] pip install matplotlib
36 [2024-04-17 15:00:10] pip install requests
37 [2024-04-17 15:00:14] python topology_optimization_cantilever_beam.py
when install packages, it have these conficts but it give error as before
requests-ntlm 1.2.0 requires cryptography>=1.3, which is not installed.
ansys-simai-core 0.1.4 requires requests_toolbelt<2,>=1.0.0, which is not installed.
ansys-dynamicreporting-core 0.5.1 requires filelock>=3.7.1, which is not installed.
ansys-dynamicreporting-core 0.5.1 requires pytz>=2021.3, which is not installed.
ansys-fluent-core 0.19.2 requires lxml>=4.9.2, which is not installed.
ansys-fluent-core 0.19.2 requires pandas>=1.1.5, which is not installed.
ansys-fluent-core 0.19.2 requires pyyaml>=6.0, which is not installed.
twine 5.0.0 requires keyring>=15.1, which is not installed.
twine 5.0.0 requires pkginfo>=1.8.1, which is not installed.
twine 5.0.0 requires requests-toolbelt!=0.9.0,>=0.8.0, which is not installed.
ansys-additive-core 0.17.2 requires pandas>=1.3.2, which is not installed.
ansys-additive-core 0.17.2 requires panel>=1.2.1, which is not installed.
ansys-geometry-core 0.4.11 requires scipy<2,>=1.7.3, which is not installed.
python-keycloak 2.0.0 requires urllib3<2.0.0,>=1.26.0, but you have urllib3 2.2.1 which is incompatible.
ansys-dynamicreporting-core 0.5.1 requires urllib3<2.0.0, but you have urllib3 2.2.1 which is incompatible.
ansys-pyensight-core 0.7.8 requires urllib3<2, but you have urllib3 2.2.1 which is incompatible.
pyansys 2024.1.7 requires ansys-mechanical-core==0.10.8, but you have ansys-mechanical-core 0.10.9 which is incompatible.
FYI: I found that there is a package pyansys-docker, but docker is not availabe on HPC, does it affect?
@zueskalare Sorry for delay in response. That should not be an issue. If you just want to work with pymechanical I would suggest install only pymechanical package in your venv and test. You can do following.
conda create py_mech
conda create -n py_mech python==3.11
conda activate py_mech
pip install -U ansys-mechanical-core
pip install matplotlib
pip install requests
xvfb-run mechanical-env python topology_optimization_cantilever_beam.py
use xvfb-run
if you are running in system without graphic display. mechanical-env
should be used before you run the python script. Please try and let me know.
Thanks, xvfb-run makes it works now.
Discussed in https://github.com/ansys/pymechanical/discussions/698