简体   繁体   English

如何在 macos 上安装 manim?

[英]How can I install manim on macos?

I'm trying to install manim on mac, however I'm clueless as how the terminal and everything works, I'm just following tutorials anf copy/pasting stuff in the console.我正在尝试在 mac 上安装 manim,但是我对终端和一切的工作方式一无所知,我只是按照教程和控制台中的复制/粘贴内容进行操作。 I'm doing pip install manimlib on the terminal, which should install the package, but I get the following error :我正在终端上执行pip install manimlib ,它应该安装包,但出现以下错误:

Building wheels for collected packages: pycairo
  Building wheel for pycairo (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/anaconda3/bin/python /opt/anaconda3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/d7/5ck284fd7t9130wpwl62rkwh0000gn/T/tmpmazoiavw
       cwd: /private/var/folders/d7/5ck284fd7t9130wpwl62rkwh0000gn/T/pip-install-ip_5iqrw/pycairo_705073eb1a214eec8f3c3913abe5de7f
  Complete output (12 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.7
  creating build/lib.macosx-10.9-x86_64-3.7/cairo
  copying cairo/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/cairo
  copying cairo/__init__.pyi -> build/lib.macosx-10.9-x86_64-3.7/cairo
  copying cairo/py.typed -> build/lib.macosx-10.9-x86_64-3.7/cairo
  running build_ext
  Requested 'cairo >= 1.15.10' but version of cairo is 1.14.12
  Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for pycairo
Failed to build pycairo
ERROR: Could not build wheels for pycairo which use PEP 517 and cannot be installed directly

I tried reading some question on stack overflow but none of the answers seemed to work for me.我尝试阅读有关堆栈溢出的一些问题,但似乎没有一个答案对我有用。 I understand nothing about what is written here, what should I write in my console to be able to install manim properly ?我对这里写的内容一无所知,我应该在控制台中写什么才能正确安装 manim? Thanks in advance guys :)在此先感谢各位:)

I don't know much about Manim, but I'm pretty familiar with the error message you're currently getting because it's related to a project I'm working on myself.我对 Manim 了解不多,但我对您目前收到的错误消息非常熟悉,因为它与我自己正在从事的项目有关。

The reason your install isn't working is because the Manim library has several dependencies that have to be installed in order for it to work properly (at least according to the documentation on their website ).您的安装不起作用的原因是 Manim 库有几个依赖项,必须安装这些依赖项才能正常工作(至少根据他们网站上的文档)。 One of these dependencies is Pycairo, which is a Python interface for Cairo, a vector graphics library written in C. My guess would be that Pycairo does the heavy lifting when it comes to drawing things in Manim.其中一个依赖项是 Pycairo,它是 Cairo 的 Python 接口,Cairo 是一个用 C 编写的矢量图形库。我猜想在 Manim 中绘制事物时,Pycairo 会承担繁重的工作。

Whenever you run a pip installation, the built-in package manager will read all of the dependencies that the package you're trying to install has, and it will install those packages as well.每当您运行 pip 安装时,内置的包管理器将读取您尝试安装的包所具有的所有依赖项,并且它也会安装这些包。 That's what pip is doing right now with Pycairo.这就是 pip 现在对 Pycairo 所做的事情。 However, unfortunately with MacOS, the Cairo binary files (ie the code compiled from C that allows Pycairo to run properly) are not included in the pip installation like it is with some other operating systems like Windows, so it causes this error message you're seeing.然而,不幸的是,对于 MacOS,Cairo 二进制文件(即从 C 编译的允许 Pycairo 正常运行的代码)不包含在 pip 安装中,就像 Windows 等其他一些操作系统一样,因此它会导致此错误消息重见。 This issue with MacOS is actually what brought me to your post. MacOS 的这个问题实际上是让我看到你的帖子的原因。

To fix the issue, you'll need to install Cairo manually using something called Homebrew, which is a useful package manager that lets you install packages right from the Mac terminal.要解决此问题,您需要使用 Homebrew 手动安装 Cairo,这是一个有用的包管理器,可让您直接从 Mac 终端安装包。 The instructions for how to install Homebrew, as well as how to install Cairo and some other Manim dependencies via Homebrew, are included in that documentation page I linked above.关于如何安装 Homebrew 以及如何通过 Homebrew 安装 Cairo 和其他一些 Manim 依赖项的说明包含在我上面链接的那个文档页面中。

After you do all that, you should be able to run this pip installation again and it should work.完成所有这些之后,您应该能够再次运行此 pip 安装并且它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM