如何在 MacOS 上安装 Mayavi
我想用Python创建一些图形,而Matplotlib似乎在3D表面上绘制封闭曲线方面似乎无法做得很好。一些在线研究导致我去Mayavi.mlab完成了该任务( matplotlib:3D表面顶部的图3D曲线)。我目前正在运行Python 3.7.11,但是如有必要,我可以升级到3.9或更高。我尝试了多种安装Mayavi的方法,并且所有这些方法都以一种或另一种方式失败,包括这里一些相关问题的答案。这是我的症状:
使用Anaconda,
我尝试了conda install mayavi
和conda 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:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
安装VTK本身(不仅仅是vtk的python pip包)也是Mayavi的先决条件。
(仅限 MacOS:)
以下步骤安装 VTK 和 Mayavi:
先决条件:
brew install llvm
。这需要在brew info llvm
中手动安装步骤。pip installwheel
# 可选。我是在其他步骤之前完成的。步骤:
brew install vtk
# 非常重pip install vtk
pip install mayavi
(不需要,但由于某种原因我需要它)brew install qt5
brew info qt5
# 慢#
按照上述说明操作。 (为编译器设置PATH
以及LDFLAGS
和CPPFLAGS
)并关闭并打开终端。qmake
# 测试qmake
在终端上的工作情况(测试qt5的PATH
)pip install pyqt5
#慢:使用 clang 构建。导出 ETS_TOOLKIT=
导出QT_API=pyqt5
brew install pyside
# (我在前面的步骤中也安装了pyside
。可能没有必要)我还做了很多其他事情,但这是重现有效步骤的步骤。我希望我没有错过我所做的事情(或者如果有不必要的步骤)。由于它更改了配置,因此很难恢复并从头开始测试。
这将安装以下版本的组合:
[电子邮件受保护]< /代码>,<代码>qt5。
还有clang 13.1.6。
它会安装VTK和Mayavi。
请注意,我使用
venv
,因此如果您使用conda
,则确切的pip
命令可能会有所不同。测试于:
Python:
3.9.13
,MacOS:12.4 蒙特利 M1Installing 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:
brew install llvm
. which requires manual installation steps inbrew info llvm
.pip install wheel
# optional. I did it before other steps.Steps:
brew install vtk
# very heavypip install vtk
pip install mayavi
(not needed, but for some reason I needed it)brew install qt5
brew info qt5
# slow#
Follow instructions of above. (SetPATH
plusLDFLAGS
andCPPFLAGS
for compiler) and close and open the terminal.qmake
# Testqmake
works on terminal (to test thePATH
of qt5)pip install pyqt5
# Slow: builds using clang.export ETS_TOOLKIT=
export QT_API=pyqt5
brew install pyside
# (I installedpyside
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 exactpip
command may differ for you if you useconda
.Tested on:
Python:
3.9.13
, MacOS: 12.4 Monterey M1我使用MacPorts安装了Mayavi版本4.8.2。
步骤:
我一直在努力在过去两个月使用Macports安装Mayavi。上面的步骤有效!
I installed Mayavi version 4.8.2 using MacPorts.
Steps:
I had been struggling in installing Mayavi using MacPorts for the last two months. The steps above worked!