import freetype: AttributeError: function 'FT_Get_BDF_Charset_ID' not found

将从 https://github.com/ubawurinna/freetype-windows-binaries 下载下来的dll

放置到c:\windows\system32\ 下之后

import freetype 终于不报

>>> import freetype
Traceback (most recent call last):
  File "D:\venv\jupyter\lib\site-packages\freetype\raw.py", line 34, in <module>
 
    _lib = ctypes.CDLL(filename)
  File "c:\Python35\Lib\ctypes\__init__.py", line 351, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\venv\jupyter\lib\site-packages\freetype\__init__.py", line 21, in <module>
    from freetype.raw import *
  File "D:\venv\jupyter\lib\site-packages\freetype\raw.py", line 37, in <module>
 
    raise RuntimeError('Freetype library not found')
RuntimeError: Freetype library not found
>>>

 

但是:却报错:

>>> import freetype
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\venv\jupyter\lib\site-packages\freetype\__init__.py", line 21, in <module>
    from freetype.raw import *
  File "D:\venv\jupyter\lib\site-packages\freetype\raw.py", line 190, in <module>
    FT_Get_BDF_Charset_ID          = _lib.FT_Get_BDF_Charset_ID
  File "c:\Python35\Lib\ctypes\__init__.py", line 364, in __getattr__
    func = self.__getitem__(name)
  File "c:\Python35\Lib\ctypes\__init__.py", line 369, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'FT_Get_BDF_Charset_ID' not found
>>>

 

解决方案就是把

D:\venv\jupyter\lib\site-packages\freetype\raw.py

相应的行(我这儿出现过两行)屏蔽掉,

#FT_Get_BDF_Charset_ID          = _lib.FT_Get_BDF_Charset_ID
#FT_Get_BDF_Property            = _lib.FT_Get_BDF_Property

 

原因:怀疑从git上下载的dll较老,用dependence walker查,确实没有 FT_Get_BDF_Charset_ID 和 FT_Get_BDF_Property

如下图示:



 

猜你喜欢

转载自kissmett.iteye.com/blog/2409899