【发布时间】:2023-04-01 20:13:01
【问题描述】:
使用 WeasyPrint,我需要执行以下操作才能获取所需的库:
sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
我已在构建时将其添加到我的 GitHub 触发器中:
- name: Install WeasyPrint dependencies
run: |
cd /home
sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
并且当我查看构建日志时,它显示它是成功的;但是,Python 应用程序仍然无法启动,说它找不到所需的库:
OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': libcairo.so.2: cannot open shared
No such file or directory
cannot load library 'libcairo.2.dylib': libcairo.2.dylib: cannot open
No such file or directory
cannot load library 'libcairo-2.dll': libcairo-2.dll: cannot open
No such file or directory
我尝试做what another user did(似乎成功)并通过SSH登录直接安装它,但是当我尝试这样做时,apt-get会抛出404错误,例如:
(antenv) root@13f25a3adfa1:/tmp/8d947bb726491c3# apt-get install libcairo2
Reading package lists... Done
Building dependency tree
[. . .]
Fetched 4156 kB in 0s (4207 kB/s)
E: Failed to fetch http://security.debian.org/debian-security/pool/updates/main/libx/libx11/libx11-data_1.6.4-3+deb9u3_all.deb 404 Not Found
E: Failed to fetch http://security.debian.org/debian-security/pool/updates/main/libx/libx11/libx11-6_1.6.4-3+deb9u3_amd64.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Azure 应用服务是否不再允许您执行此操作?我不知道下一步该尝试什么。
编辑: 因此,我能够通过 SSH 连接到机器并首先运行 apt-get update 来添加所有依赖项。但是,我仍然遇到我的 Python 应用程序仍然无法运行的问题。即使安装了库,我也看到以下错误:
2021-07-19T14:43:06.741297128Z OSError: no library called "cairo" was found
2021-07-19T14:43:06.741300828Z no library called "libcairo-2" was found
2021-07-19T14:43:06.741304429Z cannot load library 'libcairo.so.2': libcairo.so.2: cannot open shared object file: No such file or directory
2021-07-19T14:43:06.741308229Z cannot load library 'libcairo.2.dylib': libcairo.2.dylib: cannot open shared object file: No such file or directory
2021-07-19T14:43:06.741311929Z cannot load library 'libcairo-2.dll': libcairo-2.dll: cannot open shared object file: No such file or directory
【问题讨论】:
-
不是 pip 安装?
-
pip 在这里不相关。需要安装的库不能用 pip 安装,这就是为什么我尝试使用 apt-get 先安装它们,就像他们的文档建议的那样。
标签: azure azure-web-app-service django-weasyprint