如何在 MacOS 上安装 Mayavi

发布于 2025-01-18 03:26:13 字数 1471 浏览 1 评论 0原文

我想用Python创建一些图形,而Matplotlib似乎在3D表面上绘制封闭曲线方面似乎无法做得很好。一些在线研究导致我去Mayavi.mlab完成了该任务( matplotlib:3D表面顶部的图3D曲线)。我目前正在运行Python 3.7.11,但是如有必要,我可以升级到3.9或更高。我尝试了多种安装Mayavi的方法,并且所有这些方法都以一种或另一种方式失败,包括这里一些相关问题的答案。这是我的症状:

使用Anaconda,

我尝试了conda install mayaviconda install -c conda -forge mayavi。他们俩都有相同的问题,而“冷冻解决方案”无法“解决环境”。然后,它尝试灵活的解决方案,但仍然失败。然后它尝试了不同的回购,并且再次无法用冷冻溶液解决环境。

我还尝试了同一件事的Anaconda Navigator,但是在一个名为“解决方案依赖关系”的步骤中,它悬挂了大约六个小时,此时我停止了它。

在PIP上,

另一个网站告诉我,PIP轮毂更可靠地安装Mayavi,但是您应该在Mayavi之前先安装PIP VTK。因此,我做到了:PIP Install VTK,然后pip install mayavi。在安装过程中,两种似乎都可以工作,因为我没有能告诉我的警告或错误。但是,一旦我尝试在jupyter笔记本中导入mayavi,我就会得到此错误:

”

这对我的新手眼睛看起来像是某种QT接口的问题,但是除此之外,我不知道发生了什么。

总结,

我显然不是Python的专家,但我不知道该尝试什么。通常,Conda似乎能够找出包裹依赖项并安装所需的内容,但这次不是。我会为任何建议感到高兴,如果我遗漏了一些重要信息,我会提前道歉。问题是否是由于使用Python 3.7的Anaconda3版本而引起的,但是使用PIP安装Mayavi?无论如何,我都希望与Anaconda一起安装Mayavi,因此我很感谢有关如何做到这一点的任何指控。

I would like to create some graphics with Python that matplotlib seems to be unable to do well, in terms of drawing closed curves on 3D surfaces. A bit of online research led me to mayavi.mlab for that task (Matplotlib: Plot 3D curve on top of 3D surface). I am currently running Python 3.7.11, but I can upgrade to 3.9 or higher if necessary. I have tried multiple ways to install mayavi and all of them fail in one way or another, including the answers to some of the related questions here. Here are my symptoms:

With Anaconda

I tried both conda install mayavi and conda install -c conda-forge mayavi from the command line. Both of them have the same problem, which is being unable to "Solve the environment" with "frozen solve". Then it tries a flexible solve and still fails. Then it tries a different repo and again is unable to solve the environment with frozen solve.

I also tried Anaconda Navigator for the same thing, but it hangs during a step called "Solving package dependencies" for about six hours, at which point I stopped it.

With pip

Another website told me that pip wheels are more reliable for installing mayavi, but that you should pip install vtk first before mayavi. So I did that: pip install vtk and then pip install mayavi. Both seemed to work during install, in the sense that there were no warnings or errors that I could tell. But as soon as I try to import mayavi in a jupyter notebook I get this error:

Mayavi error part I
Mayavi error part II

This looks to my novice eyes like a problem with a Qt interface of some kind, but beyond that I don't know what is going on.

Summary

I'm obviously not an expert at Python but I don't know what else to try. Usually conda seems to be able to figure out package dependencies and install what is needed but not this time. I would be happy for any advice, and I apologize in advance if I have left out some important information. Is the problem due to using the anaconda3 version of python 3.7 but installing mayavi with pip? I would prefer to install mayavi with anaconda anyway so I would appreciate any pointers about how to do that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一花一树开 2025-01-25 03:26:13

安装VTK本身(不仅仅是vtk的python pip包)也是Mayavi的先决条件。

(仅限 MacOS:)

以下步骤安装 VTKMayavi

先决条件:

  1. brew install llvm。这需要在 brew info llvm 中手动安装步骤。
  2. pip installwheel # 可选。我是在其他步骤之前完成的。

步骤:

  1. brew install vtk # 非常重

  2. pip install vtk

  3. pip install mayavi (不需要,但由于某种原因我需要它)

  4. brew install qt5

  5. brew info qt5 # 慢

  6. # 按照上述说明操作。 (为编译器设置PATH以及LDFLAGSCPPFLAGS)并关闭并打开终端。

  7. qmake # 测试qmake在终端上的工作情况(测试qt5的PATH

  8. pip install pyqt5 #慢:使用 clang 构建。

  9. 导出 ETS_TOOLKIT=

  10. 导出QT_API=pyqt5

  11. brew install pyside # (我在前面的步骤中也安装了 pyside。可能没有必要)

我还做了很多其他事情,但这是重现有效步骤的步骤。我希望我没有错过我所做的事情(或者如果有不必要的步骤)。由于它更改了配置,因此很难恢复并从头开始测试。

这将安装以下版本的组合:[电子邮件受保护]< /代码>,<代码>qt5。
还有clang 13.1.6。

它会安装VTKMayavi

请注意,我使用 venv,因此如果您使用 conda,则确切的 pip 命令可能会有所不同。

测试于:
Python:3.9.13,MacOS:12.4 蒙特利 M1

Installing VTK itself (not just python pip package of vtk) is also a prerequisite for Mayavi.

(MacOS only:)

The following steps install both VTK and Mayavi:

Prerequisites:

  1. brew install llvm. which requires manual installation steps in brew info llvm.
  2. pip install wheel # optional. I did it before other steps.

Steps:

  1. brew install vtk # very heavy

  2. pip install vtk

  3. pip install mayavi (not needed, but for some reason I needed it)

  4. brew install qt5

  5. brew info qt5 # slow

  6. # Follow instructions of above. (Set PATH plus LDFLAGS and CPPFLAGS for compiler) and close and open the terminal.

  7. qmake # Test qmake works on terminal (to test the PATH of qt5)

  8. pip install pyqt5 # Slow: builds using clang.

  9. export ETS_TOOLKIT=

  10. export QT_API=pyqt5

  11. brew install pyside # (I installed pyside too, at earlier steps. It might be unnecessary)

I did many other things as well but this is the steps to reproduce the effective steps. I hope I haven't missed something that I have done (or if there are unnecessary steps). Since it changes the configs, it is difficult to revert back and test from scratch.

This installs the combination of following versions: [email protected], qt5.
Also clang 13.1.6 .

Which installs both VTK and Mayavi.

Note, I use venv, so the exact pip command may differ for you if you use conda.

Tested on:
Python: 3.9.13, MacOS: 12.4 Monterey M1

十年不长 2025-01-25 03:26:13

我使用MacPorts安装了Mayavi版本4.8.2。

步骤:

  1. 端口安装VTK +Python39
  2. 端口安装py39-mayavi

我一直在努力在过去两个月使用Macports安装Mayavi。上面的步骤有效!

I installed Mayavi version 4.8.2 using MacPorts.

Steps:

  1. port install vtk +python39
  2. port install py39-mayavi

I had been struggling in installing Mayavi using MacPorts for the last two months. The steps above worked!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文