VTK导入错误,尝试使用PyMAPDL时发生。

huangapple go评论109阅读模式
英文:

VTK import error when trying to using PyMAPDL

问题

在复制 PyMAPDL 中已解决的示例时 https://mapdl.docs.pyansys.com/version/stable/examples/gallery_examples/00-mapdl-examples/exhaust_manifold_thermal_stress.html

我发现了与 VTK 相关的错误,以下是错误信息:

ImportError: 无法从 'pyvista._vtk' 中导入名称 'VTK9' (c:\Users\yashp\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvista_vtk.py)

我尝试使用较低版本的 pyvista 但也不起作用。
请告诉我出了什么问题以及如何修复它?

英文:

While replicating solved Example from PyMAPDL https://mapdl.docs.pyansys.com/version/stable/examples/gallery_examples/00-mapdl-examples/exhaust_manifold_thermal_stress.html

I m finding the error with VTK and following is the error

ImportError: cannot import name 'VTK9' from 'pyvista._vtk' (c:\Users\yashp\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvista_vtk.py)

I have try to use lower version of pyvista but that also doesnt work for me.
Let me know What is wrong and how can I fix this?

答案1

得分: 1

这个答案应该是一个注释,但太长无法一次性显示。

> 我尝试使用较低版本的PyVista,但对我来说也没有用。

你应该更具体地提到你使用的版本以及“不起作用”的较低版本是什么。

PyVista将其支持的最低VTK版本提高到了9.0 在此PR中,该版本随着PyVista 0.39.0 一起发布,这是两周前的事情。这也是 pyvista._vtk.VTK9 被移除的时候。

所以,如果你降级到PyVista 0.38.6或更早的版本,应该pyvista._vtk.VTK9。请再次检查你尝试的版本,以及你是否在正确的环境中降级了PyVista。

此外,你在问题中提到的路径:
> c:\Users\yashp\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvista_vtk.py

看起来不太对。它似乎在引用一个名为 pyvista_vtk.py 的模块,这看起来从一开始就不对,而且如果考虑到 site-packages\ 文件夹中几乎没有 .py 文件,而且据我所知,任何与 pyvista 有关的内容都应该位于名为 pyvista 的目录中,所以路径应该以 site-packages\pyvista\_vtk.py 结尾。

所以,如果在正确的环境中正确降级PyVista没有起作用,请在你的问题中解释你的环境是如何创建的,你使用了什么工具(venv、conda等)来创建它,以及 pyvista.Report() 告诉你什么。

英文:

This answer should be a comment but it's too long to fit into one.

> I have try to use lower version of pyvista but that also doesnt work for me.

You should be more specific about the version you have and the lower version that "didn't work".

PyVista increased its lowest supported VTK version to 9.0 in this PR, which was released with PyVista 0.39.0 two weeks ago. This is when pyvista._vtk.VTK9 was removed.

So if you downgrade PyVista to 0.38.6 or older you should have pyvista._vtk.VTK9. Please check again what versions you tried, and whether you downgraded PyVista in the right environment.

Furthermore, the path you have in your question:
> c:\Users\yashp\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvista_vtk.py

doesn't look quite right. It looks as if it were referring to a module called pyvista_vtk.py, which looks wrong to begin with, and it's even more wrong if we consider that .py files are few and far between in site-packages\ folders, and anything pyvista should be located in a directory called pyvista as far as I know, so the path should end with site-packages\pyvista\_vtk.py.

So if properly downgrading PyVista in the correct env doesn't work, please explain in your question how your env was created, what tool (venv, conda etc.) you used to create it, and what pyvista.Report() tells you.

答案2

得分: 1

你的问题的解决方法是将 pyvista 降级到 0.37.0 版本。

查看此链接中提供的解决方法:https://github.com/ansys/pymapdl/issues/2058

如果降级 pyvista 不是一个选项(正如你似乎提到的),你可以直接从主分支安装 pymapdl(克隆存储库并使用 pip install . 安装),因为该版本可以正常工作。

英文:

The solution to your problem is to downgrade pyvista to 0.37.0.

Check the solution given in here: https://github.com/ansys/pymapdl/issues/2058

If downgrading pyvista is not an option (as you seems to mention), you can install pymapdl directly from the main branch (cloning the repo and installing it using pip install .) since that version works.

huangapple
  • 本文由 发表于 2023年5月17日 13:39:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76268856.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定