Closed lstubbig closed 11 months ago
@klmcadams could you please look into this?
Hi, did you have look at this problem? We soon have to decide on an approach for automating our simulations and Anaconda is the only approved Python distribution at the company.
Hi, did you have look at this problem? We soon have to decide on an approach for automating our simulations and Anaconda is the only approved Python distribution at the company.
Hi, I haven't had a chance to look at it, but I will look at it today and let you know. Thanks for your patience!
Hi @lstubbig, I wasn't able to recreate the error you were seeing using ansys-mechanical-core==0.10.1 and grpcio==1.57.0. Could you try recreating your conda environment and installing ansys-mechanical-core==0.10.2 and grpcio==1.58.0? Those were the only differences I saw between our pip freeze outputs. I attached a video following the steps to reproduce above. Please let me know if this works or if you are still seeing the error. Thanks!
Thanks for running the test! Unfortunately the exactly list of packages still results in the same error message. I am using Anaconda Prompt and tried ansys-mechanical-core==0.10.1 and 0.10.2, both with grpcio==1.58.0:
(pymech2) C:\Users\XXX\Documents>python --version
Python 3.11.5
(pymech2) C:\Users\XXX\Documents>pip freeze
ansys-api-mechanical==0.1.0
ansys-api-platform-instancemanagement==1.0.0
ansys-mechanical-core==0.10.2
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc1
ansys-tools-path==0.3.1
appdirs==1.4.4
cffi==1.15.1
click==8.1.7
clr-loader==0.2.6
colorama==0.4.6
grpcio==1.58.0
importlib-metadata==6.8.0
platformdirs==3.10.0
protobuf==3.20.3
pycparser==2.21
tqdm==4.66.1
zipp==3.17.0
(pymech2) C:\Users\XXX\Documents>type pymech-test.py
from ansys.mechanical.core import launch_mechanical
mech = launch_mechanical()
print(mech.version)
(pymech2) C:\Users\XXX\Documents>python pymech-test.py
CRITICAL - - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "C:\Users\XXX\Documents\pymech-test.py", line 3, in <module>
mech = launch_mechanical()
^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\Anaconda3\envs\pymech2\Lib\site-packages\ansys\mechanical\core\mechanical.py", line 2235, in launch_mechanical
raise exception
File "C:\ProgramData\Anaconda3\envs\pymech2\Lib\site-packages\ansys\mechanical\core\mechanical.py", line 2220, in launch_mechanical
port = launch_grpc(port=port, verbose=verbose_mechanical, **start_parm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\Anaconda3\envs\pymech2\Lib\site-packages\ansys\mechanical\core\mechanical.py", line 1909, in launch_grpc
raise VersionError("The Mechanical gRPC interface requires Mechanical 2023 R1 or later.")
ansys.mechanical.core.errors.VersionError: The Mechanical gRPC interface requires Mechanical 2023 R1 or later.
The executable is correctly found:
(pymech2) C:\Users\XXX\Documents>python
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ansys.mechanical.core as a
>>> a.find_mechanical()
('C:\\Program Files\\ANSYS Inc\\v232\\aisol\\bin\\winx64\\AnsysWBU.exe', 23.2)
What else could I try?
@lstubbig There's a version argument, like this launch_mechanical(version=232)
, but looking at it, the version is ignored unless pypim is used. (that's a documented limitation but we should support it)
try running ansys.tools.path.version_from_path("mechanical", "")
, this is what launch_mechanical internally uses to find the version, before it ever tries to start the process.
import ansys.tools.path
ansys.tools.path.version_from_path("mechanical", "")
If ansys.tools.path.version_from_path("mechanical", "")
returns 231, but find_mechanical
returns 232, then this is a bug in the ansys.tools.path library.
@koubaa Here's the output. It looks like ansys.tools.path.version_from_path("mechanical", "")
does return the correct version.
(pymech2) C:\Users\XXX>python
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ansys.tools.path
>>> import ansys.mechanical.core as a
>>> apath = a.find_mechanical()[0]
>>> apath
'C:\\Program Files\\ANSYS Inc\\v232\\aisol\\bin\\winx64\\AnsysWBU.exe'
>>> ansys.tools.path.version_from_path("mechanical", apath)
232
>>> a.find_mechanical()
('C:\\Program Files\\ANSYS Inc\\v232\\aisol\\bin\\winx64\\AnsysWBU.exe', 23.2)
Is this what you would expect as normal behaviour? launch_mechanical(version=232)
results in the same VersionError as above.
@lstubbig
Until #419 is fixed the version
argument of launch_mechanical
won't have an effect for you.
I see one more block of code that might be responsible.
try running this: ansys.tools.path.get_mechanical_path(False)
Hi, thanks again for the help. I got around to testing it and this is the output:
(pymech2) C:\Users\XXX>python
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ansys.tools.path
>>> ansys.tools.path.get_mechanical_path(False)
'C:\\Program Files\\ANSYS Inc\\v212\\aisol\\bin\\winx64\\AnsysWBU.exe'
This seems to point at the old version (21.2)! I have it on my machine (2019R3, 2021R2 and 2023R2), so the path exists.
@lstubbig I filed a bug to the ansys.tools.path project, I think it needs to be fixed there. I did miss one thing, I wanted to know the output of ansys.tools.path.version_from_path("mechanical", "")
when the second argument is an empty string, not ansys.mechanical.core.find_mechanical()[0]
.
ansys.tools.path will store the results of its search in your appdata folder under platformdirs.user_data_dir(appname="ansys_tools_path", appauthor="Ansys")
which for me evaluates to
'C:\Users\mkoubaa\AppData\Local\Ansys\ansys_tools_path'
Can you please attach the contents of that folder to this bug, we can use it to fix the issue. In the meantime, you can try removing that folder and that should reset the behavior of ansys.tools.path.
@koubaa Here's the output of ansys.tools.path.version_from_path("mechanical", "")
:
(pymech2) C:\Users\XXX>python
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ansys.tools.path
>>> ansys.tools.path.version_from_path("mechanical", "")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\pymech2\Lib\site-packages\ansys\tools\path\path.py", line 909, in version_from_path
return _mechanical_version_from_path(path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\Anaconda3\envs\pymech2\Lib\site-packages\ansys\tools\path\path.py", line 864, in _mechanical_version_from_path
raise RuntimeError(f"Unable to extract Mechanical version from {path}.")
RuntimeError: Unable to extract Mechanical version from .
There was one file in C:\Users\XXX\AppData\Local\Ansys\ansys_tools_path
, which points at 2021R2. I attached it here: config.txt
After deleting it PyMechanical launches!
@lstubbig great! Since this issue is now tracked in the ansys.tools.path project, I am closing this issue. cc @samigithub2022 @klmcadams @dipinknair
π Before submitting the issue
π Description of the bug
Hi, I am trying to use pymechanical with a conda environment and Ansys 2023 R2 on a Windows machine. I followed the normal installation steps (see below) and Workbench 2023 R2 is running.
pymechanical also finds the path to AnsysWBU.exe:
However, trying to verify the installation results in a gRPC error (VersionError: The Mechanical gRPC interface requires Mechanical 2023 R1 or later.):
Not sure if this is a bug (Anys 2023 R2 is later than R1 and available) or a problem with my setup. Any ideas?
π Steps to reproduce
π» Which operating system are you using?
Windows
π Which ANSYS version are you using?
2023 R2
π Which Python version are you using?
3.11
π¦ Installed packages