MyreMylar / pygame_gui

A GUI system for pygame.
MIT License
698 stars 83 forks source link

ImportError: cannot import name 'DIRECTION_LTR' from 'pygame' #611

Closed W5DEV closed 3 months ago

W5DEV commented 4 months ago

Describe the bug When using the Quick Start Guide, I am constantly getting the following error: ImportError: cannot import name 'DIRECTION_LTR' from 'pygame'

I am using an M1 Macbook Pro and my code is exactly as the quick start guide shows, with corrected formatting.

Quick Start Guide Code:

Screenshot 2024-06-30 at 2 50 57 AM

My Code:

Screenshot 2024-06-30 at 2 51 26 AM

To Reproduce Steps to reproduce the behavior:

  1. Install pygame
  2. Test initial code in QuickStartGuide (this works fine)
  3. Install pygame_gui using the exact commands in the QuickStartGuide
  4. Test the next block of code

Expected behaviour I expect that when I run the next block of code (or any code with pygame_gui imported), I don't get any bugs. This code, for example, should render the window with a button. However it also crashes:

Screenshot 2024-06-30 at 2 53 08 AM

Screenshots If applicable, add screenshots to help explain your problem.

Platform and software (please complete the following information):

Additional context

Traceback:

pygame 2.6.0 (SDL 2.28.4, Python 3.12.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/Users/jl/Desktop/GitHub/python-legends-and-legacies/game_window.py", line 2, in <module>
    import pygame_gui
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pygame_gui/__init__.py", line 7, in <module>
    from pygame_gui.ui_manager import UIManager
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pygame_gui/ui_manager.py", line 8, in <module>
    from pygame_gui.core.interfaces import IUIManagerInterface
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pygame_gui/core/__init__.py", line 1, in <module>
    from pygame_gui.core.ui_appearance_theme import UIAppearanceTheme
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pygame_gui/core/ui_appearance_theme.py", line 11, in <module>
    from pygame_gui.core.interfaces.gui_font_interface import IGUIFontInterface
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pygame_gui/core/interfaces/__init__.py", line 2, in <module>
    from pygame_gui.core.interfaces.font_dictionary_interface import IUIFontDictionaryInterface
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pygame_gui/core/interfaces/font_dictionary_interface.py", line 2, in <module>
    from pygame import DIRECTION_LTR
ImportError: cannot import name 'DIRECTION_LTR' from 'pygame' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pygame/__init__.py)
NFB418 commented 4 months ago

This is the same issue as discussed here: https://github.com/MyreMylar/pygame_gui/issues/587

I also had this, in my case I unknowingly had both pygame and pygame-ce installed in the environment I was using. The solution was to first uninstall pygame AND uninstall pygame-ce, and THEN install pygame-ce in the environment.

Dependent on what exactly your situation is, this should hopefully fix things for you the same way it did for me!

W5DEV commented 3 months ago

This is the same issue as discussed here: #587

I also had this, in my case I unknowingly had both pygame and pygame-ce installed in the environment I was using. The solution was to first uninstall pygame AND uninstall pygame-ce, and THEN install pygame-ce in the environment.

Dependent on what exactly your situation is, this should hopefully fix things for you the same way it did for me!

This was the fix that solved my issue. I had regular pygame installed as well. Uninstalled both, reinstalled pygame-ce and it worked.