You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can get some of this info from the text that pops up in the console when you run a pygame program.
Operating system (e.g. Windows, Linux(Debian), Linux(Ubuntu), Mac): Linux Bullseye Lite
Python version (e.g. 3.7.9, 3.8.5) : 3.12.2
SDL version (e.g. SDL 2.0.12): SDL 2.0.14
PyGame version (e.g. 2.0.0.dev10, 1.9.6): 2.5.2
Relevant hardware (e.g. if reporting a bug about a controller, tell us the brand & name of it): Raspberry Pi Zero 2W
Current behavior:
Attempting to import pygame.font causes a fatal exception with this message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.pyenv/versions/3.12.2/lib/python3.12/site-packages/pygame/font.py", line 17, in <module>
from pygame.sysfont import match_font, get_fonts, SysFont as _SysFont
File "/home/pi/.pyenv/versions/3.12.2/lib/python3.12/site-packages/pygame/sysfont.py", line 27, in <module>
from pygame.font import Font
ImportError: cannot import name 'Font' from partially initialized module 'pygame.font' (most likely due to a circular import) (/home/pi/.pyenv/versions/3.12.2/lib/python3.12/site-packages/pygame/font.py)
Looking into the indicated modules indeed reveals a circular import problem.
In font.py:
"""pygame module for loading and rendering fonts (freetype alternative)"""
...line 17:
from pygame.sysfont import match_font, get_fonts, SysFont as _SysFont
In sysfont.py, line 27:
from pygame.font import Font
Expected behavior:
Importing pygame.font should not cause a circular import error.
Screenshots
n/a
Steps to reproduce:
Please explain the steps required to duplicate the issue, especially if you are able to provide a sample application.
if the bug is caused by a specific file (image, font, sound, level, please upload it as an attachment
Install Raspberry Pi (Bullseye) Lite
Install Python via pyenv
Install pygame via pip (builds from source)
Run python and import pygame.font
Test code
import pygame
import pygame.font
The text was updated successfully, but these errors were encountered:
Hi, I also have a problem when trying to use "font" :
Python 3.6.9 (default, Mar 10 2023, 16:46:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
_frozen_importlib:219: RuntimeWarning: Your system is avx2 capable but pygame was not built with support for it. The performance of some of your blits could be adversely affected. Consider enabling compile time detection with environment variables like PYGAME_DETECT_AVX2=1 if you are compiling without cross compilation.
/home/raphael/projects/robotNav_PROJECT/robotNavVenv/lib/python3.6/site-packages/pygame-2.6.0.dev1-py3.6-linux-x86_64.egg/pygame/pkgdata.py:25: UserWarning: Module pygame was already imported from /home/raphael/projects/robotNav_PROJECT/robotNavVenv/lib/python3.6/site-packages/pygame-2.6.0.dev1-py3.6-linux-x86_64.egg/pygame/__init__.py, but /home/raphael/projects/robotNav_PROJECT/pygame is being added to sys.path
from pkg_resources import resource_stream, resource_exists
pygame 2.6.0.dev1 (SDL 2.0.8, Python 3.6.9)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> pygame.init()
(2, 0)
>>> font = pygame.font.SysFont(None, 36)
__main__:1: RuntimeWarning: use font: cannot import name 'Font'
(ImportError: cannot import name 'Font')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/raphael/projects/robotNav_PROJECT/robotNavVenv/lib/python3.6/site-packages/pygame-2.6.0.dev1-py3.6-linux-x86_64.egg/pygame/__init__.py", line 70, in __getattr__
raise NotImplementedError(missing_msg)
NotImplementedError: font module not available (ImportError: cannot import name 'Font')
I first installed pygame via pip, then uninstalled it and followed the https://www.pygame.org/wiki/CompileUbuntu instructions when using virtual environment (but I use python venv instead of mkvirtualenv).
Environment:
You can get some of this info from the text that pops up in the console when you run a pygame program.
Current behavior:
Attempting to import pygame.font causes a fatal exception with this message:
Looking into the indicated modules indeed reveals a circular import problem.
In font.py:
...line 17:
In sysfont.py, line 27:
Expected behavior:
Importing pygame.font should not cause a circular import error.
Screenshots
n/a
Steps to reproduce:
Please explain the steps required to duplicate the issue, especially if you are able to provide a sample application.
if the bug is caused by a specific file (image, font, sound, level, please upload it as an attachment
Test code
The text was updated successfully, but these errors were encountered: