Skip to main content
 首页 » 编程设计

python之如何在 Windows 7 中安装 python freetype

2024年10月25日23sharpest

我正在使用 Windows 7 64 位,我想安装和使用 freetype(来自 https://pypi.python.org/pypi/freetype-py)。我在 winpython 2.6 中安装了 gnu32 freetype6.dll 和 freetype-py。当我在我的 python 代码中导入 freetype 时,系统说:

raise RuntimeError('Freetype library not found') 
RuntimeError: Freetype library not found  

然后,我把freetype删了,用pip安装freetype 1.0。当我编译代码时,系统说:

import freetype as FT 
  File "C:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\site-packages\freetype\__init__.py", line 33, in <module> 
    if not FT_Library_filename: 
NameError: name 'FT_Library_filename' is not defined 

我无法使用 pip 安装 Freetype 2 库绑定(bind),它说:找不到任何满足 Freetype 要求的下载。

然后,我打开__init__.py,修改

FT_Library_filename = ctypes.util.find_library('freetype') 

进入:

FT_library_filename = "C:\Program Files (x86)\GnuWin32\bin\freetype.dll" 

仍然,它不起作用;系统说:

if not FT_Library_filename: 
NameError: name 'FT_Library_filename' is not defined 

有人可以帮助纠正这个问题吗?我真的需要使用 freetype。

请您参考如下方法:

根据安装指南,它指出您需要 freetype 2(复制在下方)。因此,您使用 free type 1 的 PIP 安装将无法正常工作。

Freetype-py 0.5.1

Installation

To be able to use freetype python, you need the freetype library version 2 installed on your system.

为了帮助澄清,当您说“我已经安装了 gnu32 freetype6.dll”时,您是否尝试编译自己的二进制文件或根据安装指南下载安装程序?

http://gnuwin32.sourceforge.net/install.html