我正在尝试在我的新 MacBook Pro M1 上运行一个项目
python“Flask”项目使用依赖于cairo
的md2pdf我在实现 cairographics 包时出错
我使用 sudo port install cairo 安装
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/intent_gatherer", line 11, in <module>
load_entry_point('intent-gatherer', 'console_scripts', 'intent_gatherer')()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2862, in load_entry_point
return ep.load()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2462, in load
return self.resolve()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2468, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Users/robenalam/Documents/deeplink/chatbotstrap/gatherer_backend/intent_gatherer/manage.py", line 4, in <module>
from intent_gatherer.app import create_app
File "/Users/robenalam/Documents/deeplink/chatbotstrap/gatherer_backend/intent_gatherer/app.py", line 8, in <module>
from intent_gatherer import auth, api
File "/Users/robenalam/Documents/deeplink/chatbotstrap/gatherer_backend/intent_gatherer/api/__init__.py", line 1, in <module>
from . import views
File "/Users/robenalam/Documents/deeplink/chatbotstrap/gatherer_backend/intent_gatherer/api/views.py", line 4, in <module>
from intent_gatherer.api.resources import (
File "/Users/robenalam/Documents/deeplink/chatbotstrap/gatherer_backend/intent_gatherer/api/resources/__init__.py", line 99, in <module>
from .card import (
File "/Users/robenalam/Documents/deeplink/chatbotstrap/gatherer_backend/intent_gatherer/api/resources/card.py", line 20, in <module>
from md2pdf.core import md2pdf
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/md2pdf/__init__.py", line 8, in <module>
from md2pdf.core import md2pdf # noqa
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/md2pdf/core.py", line 5, in <module>
from weasyprint import HTML, CSS
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/weasyprint/__init__.py", line 469, in <module>
from .css import preprocess_stylesheet # noqa isort:skip
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/weasyprint/css/__init__.py", line 27, in <module>
from . import computed_values, counters, media_queries
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/weasyprint/css/computed_values.py", line 15, in <module>
from .. import text
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/weasyprint/text.py", line 11, in <module>
import cairocffi as cairo
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cairocffi/__init__.py", line 48, in <module>
cairo = dlopen(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cairocffi/__init__.py", line 45, in dlopen
raise OSError(error_message) # pragma: no cover
OSError: no library called "libcairo-2" was found
cannot load library '/opt/local/lib/libcairo.dylib': dlopen(/opt/local/lib/libcairo.dylib, 2): no suitable image found. Did find:
/opt/local/lib/libcairo.dylib: mach-o, but wrong architecture
/opt/local/lib/libcairo.2.dylib: mach-o, but wrong architecture
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 2): image not found
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 2): image not found
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 2): image not found
我尝试使用 brew 安装 cairo,但由于某种原因,python 未检测到该软件包。
答案 0 :(得分:0)
转到应用程序文件夹 -> 右键单击终端应用程序 -> 获取信息
勾选使用 Rosetta 打开选项。
立即尝试。