'ModuleNotFoundError: No module named 'Foundation' when using Pythons Keyboard module

For some quick context, I was trying to make a game where you essentially would press a key and control how a symbol moves around a 2d array, however when trying to use the keyboardmodule in python, I get this error,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/Quartz/__init__.py", line 6, in <module> import AppKit File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/AppKit/__init__.py", line 10, in <module> import Foundation ModuleNotFoundError: No module named 'Foundation'

import random
import keyboard

board = [ 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","*"], 
    ["*","*","*","*","*","*","*","*","-"], 
    
]


def move_handle(): 
    while True:  
        try:  
            if keyboard.is_pressed(37): 
                print('You Pressed A Key!')
            elif keyboard.is_pressed(38): 
                print("you pressed a key") 
            elif keyboard.is_pressed(39): 
                print("you pressed a key ")
            elif keyboard.is_pressed(40): 
                print("you pressed a key")
        except:
            pass 

move_handle(board)


Solution 1:[1]

1.Are you sure if you have the module installed? If not, do pip install foundation

2.Check if your venv has the module installed, if not install it in the venv.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1