rougier / freetype-py

Python binding for the freetype library
Other
298 stars 88 forks source link

AttributeError: module 'freetype' has no attribute 'Face' #182

Closed prusso630 closed 6 months ago

prusso630 commented 6 months ago

import freetype face = freetype.Face("Vera.ttf") face.set_char_size( 48*64 ) face.load_char('S') bitmap = face.glyph.bitmap print(bitmap.buffer)

AttributeError: module 'freetype' has no attribute 'Face'

Why might there be no attribute face after pip install freetype-py on Windows 11 Pro for package 2.4.0?

prusso630 commented 6 months ago

I had to rename a file I was using from freetype python to something else...

HinTak commented 6 months ago

Already answered that question on freetype-devel. The most likely problem is that you are loading something else which contains an unrelated "freetype.py" file somewhere. This is either in your current directory, or somewhere in your python load path. Check your current directory, your PYTHONPATH environment variable, your sys.path variable inside python, and generally, read about how python searches and finds packages. There are plenty of tutorials on "python path" on Google. Lastly, try this:

import freetype
print(freetype.version())

It should print "(2, X, Y)", where X should be 10+. (current is 2, 13, 2). If it is anything else, or result in an error, you need to check your installation.