gpt4 book ai didi

python - 安装了 cairosvg 和 cairocffi 但在导入时出错

转载 作者:行者123 更新时间:2023-12-03 17:37:42 24 4
gpt4 key购买 nike

当我尝试安装 cairosvg它说要求满足。

Requirement already satisfied: cairosvg in 
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
Requirement already satisfied: cairocffi in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: lxml in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: cssselect in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: pillow in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: tinycss in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: cffi>=0.6 in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairocffi->cairosvg)
Requirement already satisfied: olefile in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from pillow->cairosvg)
Requirement already satisfied: pycparser in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cffi>=0.6->cairocffi->cairosvg)

但是当我尝试在 IDLE 中导入它时,它给出了以下错误:
import cairosvg
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairosvg\__init__.py", line 29, in <module>
from . import surface
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairosvg\surface.py", line 24, in <module>
import cairocffi as cairo
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 41, in <module>
cairo = dlopen(ffi, *CAIRO_NAMES)
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 34, in dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cffi\api.py", line 140, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cffi\api.py", line 786, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cffi\api.py", line 781, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library libcairo.so.2: error 0x7e. Additionally,
ctypes.util.find_library() did not manage to locate a library called
'libcairo.so.2'

这可能是因为 cairocffi因为它还在导入时出现以下错误:
import cairocffi
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 41, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2')
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 38, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2

我有一个基于 64 位 Windows 的架构,带有 python 3.5,并且安装了 cairocffi-0.8.0,安装没有问题。

最佳答案

我使用 UniConverter2.0 解决了这个问题.
我的环境是

  • Python 3.7
  • Windows 10 x64
  • 安装 uniconvertor-2.0rc4-win64_headless.msi ,
  • 在 UniConverter 安装路径下找到“dll”子目录。(在我的例子中,C:\Program Files\UniConvertor-2.0rc4\dlls)
  • 将此“dll”路径添加到系统路径。
  • 关闭 VSCode(或其他编辑器)并重新打开项目。
  • 尝试再次运行您的代码。
    享受!
  • 关于python - 安装了 cairosvg 和 cairocffi 但在导入时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44686194/

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