gpt4 book ai didi

加载 dll : OSError 0x7e 时 Python CFFI 模块失败

转载 作者:可可西里 更新时间:2023-11-01 14:24:38 24 4
gpt4 key购买 nike

我在 64 位 Windows 7 下运行 Python 3.3(Anaconda 发行版)。我试图安装 Weasyprint 应用程序/库,它有许多依赖项,包括 CFFI,我必须从源代码编译它,因为在二进制分发版中没有可用的兼容版本。

当我运行 weasyprint 时,它在导入加载过程中卡住,特别是当它调用 CFFI 以便为 Cairo 加载 GTK+ 库 dll 时。我得到的错误如下:

$ weasyprint
Traceback (most recent call last):
File "c:\anaconda\envs\py33\lib\site-packages\cffi-0.8-py3.3-win-amd64.egg\cffi\api.py", line 399, in _make_ffi_library
backendlib = backend.load_library(name, flags)
OSError: cannot load library libcairo-2.dll: error 0x7e

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Anaconda\envs\py33\Scripts\weasyprint-script.py", line 9, in <module>
load_entry_point('WeasyPrint==0.20', 'console_scripts', 'weasyprint')()
File "C:\Anaconda\envs\py33\lib\site-packages\pkg_resources.py", line 343, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Anaconda\envs\py33\lib\site-packages\pkg_resources.py", line 2355, in load_entry_point
return ep.load()
File "C:\Anaconda\envs\py33\lib\site-packages\pkg_resources.py", line 2061, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\__init__.py", line 309, in <module>
from .css import PARSER, preprocess_stylesheet
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\css\__init__.py", line 30, in <module>
from . import computed_values
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\css\computed_values.py", line 18, in <module>
from .. import text
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\text.py", line 18, in <module>
import cairocffi as cairo
File "c:\anaconda\envs\py33\lib\site-packages\cairocffi-0.5.1-py3.3.egg\cairocffi\__init__.py", line 39, in <module>
cairo = dlopen(ffi, 'libcairo-2.dll', 'cairo', 'libcairo-2')
File "c:\anaconda\envs\py33\lib\site-packages\cairocffi-0.5.1-py3.3.egg\cairocffi\__init__.py", line 34, in dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "c:\anaconda\envs\py33\lib\site-packages\cffi-0.8-py3.3-win-amd64.egg\cffi\api.py", line 117, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "c:\anaconda\envs\py33\lib\site-packages\cffi-0.8-py3.3-win-amd64.egg\cffi\api.py", line 405, in _make_ffi_library
backendlib = backend.load_library(path, flags)
OSError: cannot load library C:\Windows\system32\libcairo-2.dll: error 0x7e

我的环境是这样的:Windows 7.1 64位,Python 3.3 64位,我在Visual Studio 2010下编译的CFFI是64位环境,Cairo的libcairo-2.dll也是64位的-位版本。

我不是 Windows 程序员,我只是想研究这个烂摊子,因为我想让 Weasyprint 为另一个(Python 语言)项目工作。很久以前在Delphi下做过一点Windows编程,所以我对这东西的工作原理有一个模糊的了解,但是我一直无法解决这个问题。

最佳答案

我遇到了类似的错误(DLL 冲突),最终只需将 GTK 的路径(例如:“C:\gtk\bin”)移动到我的环境变量的开头即可解决。

关于加载 dll : OSError 0x7e 时 Python CFFI 模块失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20174030/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com