2

我正在按照此处概述的步骤设置用于教育目的的数学动画。我必须弄清楚如何为 Python 3.7 配置所有步骤,但这并没有造成任何重大问题。但是,我现在遇到了我不太理解的错误,这似乎来自 pycairo 包(我在下面用粗体突出了错误)。我尝试按照此处列出的步骤修复错误,但是虽然我已经成功安装了最新的 pycairo 包(1.17),但我仍然遇到相同的错误。我有一些编程经验,但我是 python 的新手,所以我不确定如何解决这个问题。任何帮助将不胜感激。

我已经发布了下面的代码(粗体错误):

(manim37) C:\Users\a1689869\Anaconda3\manim>pip install -r requirements.txt

Requirement already satisfied: argparse==1.4.0 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 1)) (1.4.0)
Requirement already satisfied: colour==0.1.5 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 2)) (0.1.5)
Requirement already satisfied: numpy==1.15.0 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 3)) (1.15.0)
Requirement already satisfied: Pillow==5.2.0 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 4)) (5.2.0)
Requirement already satisfied: progressbar==2.5 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 5)) (2.5)
Requirement already satisfied: scipy==1.1.0 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 6)) (1.1.0)
Requirement already satisfied: tqdm==4.24.0 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 7)) (4.24.0)
Requirement already satisfied: opencv-python==3.4.2.17 in c:\users\a1689869\anaconda3\envs\manim37\lib\site-packages (from -r requirements.txt (line 8)) (3.4.2.17)
Collecting pycairo==1.17.1 (from -r requirements.txt (line 9))
  Using cached https://files.pythonhosted.org/packages/68/76/340ff847897296b2c8174dfa5a5ec3406e3ed783a2abac918cf326abad86/pycairo-1.17.1.tar.gz
Building wheels for collected packages: pycairo
  **Running setup.py bdist_wheel for pycairo ... error**
  Complete output from command c:\users\a1689869\anaconda3\envs\manim37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\a1689869\\AppData\\Local\\Temp\\pip-install-cicoey3g\\pycairo\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\a1689869\AppData\Local\Temp\pip-wheel-29uyasfz --python-tag cp37:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.7
  creating build\lib.win-amd64-3.7\cairo
  copying cairo\__init__.py -> build\lib.win-amd64-3.7\cairo
  copying cairo\__init__.pyi -> build\lib.win-amd64-3.7\cairo
  copying cairo\py.typed -> build\lib.win-amd64-3.7\cairo
  running build_ext
  building 'cairo._cairo' extension
  creating build\temp.win-amd64-3.7
  creating build\temp.win-amd64-3.7\Release
  creating build\temp.win-amd64-3.7\Release\cairo
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYCAIRO_VERSION_MAJOR=1 -DPYCAIRO_VERSION_MINOR=17 -DPYCAIRO_VERSION_MICRO=1 -Ic:\users\a1689869\anaconda3\envs\manim37\include -Ic:\users\a1689869\anaconda3\envs\manim37\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\cppwinrt" /Tccairo/device.c /Fobuild\temp.win-amd64-3.7\Release\cairo/device.obj
  device.c
  **c:\users\a1689869\appdata\local\temp\pip-install-cicoey3g\pycairo\cairo\pycairo.h(37): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory**
  **error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2**

  ----------------------------------------
  **Failed building wheel for pycairo
  Running setup.py clean for pycairo
Failed to build pycairo
Installing collected packages: pycairo
  Running setup.py install for pycairo ... error**
    Complete output from command c:\users\a1689869\anaconda3\envs\manim37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\a1689869\\AppData\\Local\\Temp\\pip-install-cicoey3g\\pycairo\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\a1689869\AppData\Local\Temp\pip-record-ld4ke0sg\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\cairo
    copying cairo\__init__.py -> build\lib.win-amd64-3.7\cairo
    copying cairo\__init__.pyi -> build\lib.win-amd64-3.7\cairo
    copying cairo\py.typed -> build\lib.win-amd64-3.7\cairo
    running build_ext
    building 'cairo._cairo' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\cairo
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYCAIRO_VERSION_MAJOR=1 -DPYCAIRO_VERSION_MINOR=17 -DPYCAIRO_VERSION_MICRO=1 -Ic:\users\a1689869\anaconda3\envs\manim37\include -Ic:\users\a1689869\anaconda3\envs\manim37\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\cppwinrt" /Tccairo/device.c /Fobuild\temp.win-amd64-3.7\Release\cairo/device.obj
    device.c
    **c:\users\a1689869\appdata\local\temp\pip-install-cicoey3g\pycairo\cairo\pycairo.h(37): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2**

    ----------------------------------------
Command "c:\users\a1689869\anaconda3\envs\manim37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\a1689869\\AppData\\Local\\Temp\\pip-install-cicoey3g\\pycairo\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\a1689869\AppData\Local\Temp\pip-record-ld4ke0sg\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\a1689869\AppData\Local\Temp\pip-install-cicoey3g\pycairo\
4

2 回答 2

0

看来您正在使用 anaconda。据我所知,在为 pycairo 构建轮子时似乎存在一些问题。可能您可以尝试手动安装 pycairo,然后在 anaconda 提示符下再次重新安装 manimlib。

conda install -c conda-forge pycairo

来源 - conda-forge/pycairo

于 2019-06-11T02:51:10.697 回答
0

我有 pycairo 的问题。我已经完成了一步解决。

您需要确保正确版本的依赖关系。

要降级它们,首先卸载:

pip uninstall Pillow idna requests urllib3

然后你应该安装特定版本:

pip install Pillow==5.3.0 idna==2.6 requests==2.18.4 urllib3==1.22
于 2021-10-27T04:20:30.753 回答