ansys / pyprimemesh

Pythonic Meshing Client for Ansys Prime Server
https://prime.docs.pyansys.com/
MIT License
19 stars 9 forks source link

Cannot import `ansys.meshing.prime` when installed without `[all]` extra #857

Closed greschd closed 2 weeks ago

greschd commented 3 weeks ago

🔍 Before submitting the issue

🐞 Description of the bug

When installing the latest dev version from main without the [all] extra, importing ansys.meshing.prime raises the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\ANSYSDev\public\pyprimemesh\.venv2\lib\site-packages\ansys\meshing\prime\__init__.py", line 5, in <module>
    from ansys.meshing.prime.core.model import Model
  File "D:\ANSYSDev\public\pyprimemesh\.venv2\lib\site-packages\ansys\meshing\prime\core\model.py", line 41, in <module>
    from ansys.meshing.prime.core.mesh import Mesh
  File "D:\ANSYSDev\public\pyprimemesh\.venv2\lib\site-packages\ansys\meshing\prime\core\mesh.py", line 29, in <module>
    import pyvista as pv
ModuleNotFoundError: No module named 'pyvista'

After manually installing PyVista:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\ANSYSDev\public\pyprimemesh\.venv2\lib\site-packages\ansys\meshing\prime\__init__.py", line 5, in <module>
    from ansys.meshing.prime.core.model import Model
  File "D:\ANSYSDev\public\pyprimemesh\.venv2\lib\site-packages\ansys\meshing\prime\core\model.py", line 41, in <module>
    from ansys.meshing.prime.core.mesh import Mesh
  File "D:\ANSYSDev\public\pyprimemesh\.venv2\lib\site-packages\ansys\meshing\prime\core\mesh.py", line 30, in <module>
    from ansys.tools.visualization_interface import MeshObjectPlot
ModuleNotFoundError: No module named 'ansys.tools'

I think the root cause is that the visualization code is imported as part of the default import, but ansys-tools-visualization-interface is present only installed when the [all] extra is used on install.

📝 Steps to reproduce

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

2025R1

🐍 Which Python version are you using?

3.10

📦 Installed packages

ansys-api-meshing-prime==0.1.3
ansys-meshing-prime @ git+https://github.com/ansys/pyprimemesh.git@8f06075fd7ca3a64d7db8b5ad8abb17ed724c6ae
appdirs==1.4.4
grpcio==1.66.0
numpy==2.1.0
protobuf==4.25.4