我正在按照here概述的步骤设置用于教育目的的数学动画。我必须弄清楚如何配置Python 3.7的所有步骤,但这并没有带来任何重大问题。但是,我现在遇到了我无法完全理解的错误,它似乎来自pycairo包(我在下面以粗体突出显示了错误)。我尝试按照here概述的步骤修复错误,但是尽管我已成功安装了最新的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\
最佳答案
看来您正在使用anaconda。从我看来,为pycairo制作轮子时似乎存在一些问题。可能您可以尝试手动安装pycairo,然后在anaconda提示符下再次重新安装manimlib。conda install -c conda-forge pycairo
source - conda-forge/pycairo
关于python - 在python 3.7环境中使用manim的pycairo的构建轮子失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52905824/