Why wont my getpass work?

# ======================================================================================================================================= #

import json
import os
import getpass

# ======================================================================================================================================= #

folder_path = r"C:\folders\folders\folders"
key_file = "key.json"

# ======================================================================================================================================= #

def cool_logo():
    print("=============================================================================================================================")
    print(r"                ________   ________   ________   ________   ___  ___   ________    _________                                ")
    print(r"               |\   __  \ |\   ____\ |\   ____\ |\   __  \ |\  \|\  \ |\   ___  \ |\___   ___\                              ")
    print(r"               \ \  \|\  \\ \  \___| \ \  \___| \ \  \|\  \\ \  \\\  \\ \  \\ \  \\|___ \  \_|                              ")
    print(r"                \ \   __  \\ \  \     \ \  \     \ \  \\\  \\ \  \\\  \\ \  \\ \  \    \ \  \                               ")
    print(r"                 \ \  \ \  \\ \  \____ \ \  \____ \ \  \\\  \\ \  \\\  \\ \  \\ \  \    \ \  \                              ")
    print(r"                  \ \__\ \__\\ \_______\\ \_______\\ \_______\\ \_______\\ \__\\ \__\    \ \__\                             ")
    print(r"                   \|__|\|__| \|_______| \|_______| \|_______| \|_______| \|__| \|__|     \|__|                             ")
    print("")
    print(r"  ___   ________    ________  ________   ________   _____ ______    ________   _________   ___   ________   ________        ")
    print(r" |\  \ |\   ___  \ |\  _____\|\   __  \ |\   __  \ |\   _ \  _   \ |\   __  \ |\___   ___\|\  \ |\   __  \ |\   ___  \      ")
    print(r" \ \  \\ \  \\ \  \\ \  \__/ \ \  \|\  \\ \  \|\  \\ \  \\\__\ \  \\ \  \|\  \\|___ \  \_|\ \  \\ \  \|\  \\ \  \\ \  \     ")
    print(r"  \ \  \\ \  \\ \  \\ \   __\ \ \  \\\  \\ \   _  _\\ \  \\|__| \  \\ \   __  \    \ \  \  \ \  \\ \  \\\  \\ \  \\ \  \    ")
    print(r"   \ \  \\ \  \\ \  \\ \  \_|  \ \  \\\  \\ \  \\  \|\ \  \    \ \  \\ \  \ \  \    \ \  \  \ \  \\ \  \\\  \\ \  \\ \  \   ")
    print(r"    \ \__\\ \__\\ \__\\ \__\    \ \_______\\ \__\\ _\ \ \__\    \ \__\\ \__\ \__\    \ \__\  \ \__\\ \_______\\ \__\\ \__\  ")
    print(r"     \|__| \|__| \|__| \|__|     \|_______| \|__|\|__| \|__|     \|__| \|__|\|__|     \|__|   \|__| \|_______| \|__| \|__|  ")
    print("")
    print(r"                      _____ ______    ________   ________    ________   ________   _______    ________                      ")
    print(r"                     |\   _ \  _   \ |\   __  \ |\   ___  \ |\   __  \ |\   ____\ |\  ___ \  |\   __  \                     ")
    print(r"                     \ \  \\\__\ \  \\ \  \|\  \\ \  \\ \  \\ \  \|\  \\ \  \___| \ \   __/| \ \  \|\  \                    ")
    print(r"                      \ \  \\|__| \  \\ \   __  \\ \  \\ \  \\ \   __  \\ \  \  ___\ \  \_|/__\ \   _  _\                   ")
    print(r"                       \ \  \    \ \  \\ \  \ \  \\ \  \\ \  \\ \  \ \  \\ \  \|\  \\ \  \_|\ \\ \  \\  \|                  ")
    print(r"                        \ \__\    \ \__\\ \__\ \__\\ \__\\ \__\\ \__\ \__\\ \_______\\ \_______\\ \__\\ _\                  ")
    print(r"                         \|__|     \|__| \|__|\|__| \|__| \|__| \|__|\|__| \|_______| \|_______| \|__|\|__|             v2  ")
    print("")
    print("=============================================================================================================================")

# ======================================================================================================================================= #

def login_prompt():
    password_data = pass_key()
    while True:
        entered_password = getpass.getpass("Enter password: ")
        if entered_password == password_data.get("password"):
            break
        else:
            print("\nIncorrect password.")

# ======================================================================================================================================= #

def pass_key():
    try:
        with open(key_file, "r") as file:
            return json.load(file)
    except (FileNotFoundError, json.JSONDecodeError):
        print(" Error: Unable to locate 'key.json'.\n")
        exit()

# ======================================================================================================================================= #

def display_files():
    try:
        files = [f for f in os.listdir(folder_path) if f.endswith('.txt')]
        if files:
            print("\n[#] Account Info\n")
            for index, file in enumerate(files, 1):
                print(f"[{index}] {file[:-4]}")
            print("\n=============================================================================================================================")
            return files
        else:
            print(" Error: Missing 'Account Information'.")
            return []
    except FileNotFoundError:
        print(" Error: Folder not found.")
        return []

# ======================================================================================================================================= #

def display_file_content(file_name):
    file_path = os.path.join(folder_path, f"{file_name}.txt")
    try:
        with open(file_path, 'r') as file:
            print(f"\n{file_name}\n")
            print(file.read())
            print("\n=============================================================================================================================")
    except FileNotFoundError:
        print(f" Error: {file_name}.txt not found.")

# ======================================================================================================================================= #

def help_command():
    print("\n[-list] Lists available options.")
    print("[-exit] Exits the app.")
    print("[-help] Shows this help message.")
    print("\n=============================================================================================================================")

# ======================================================================================================================================= #

def handle_choice(choice, files):
    if choice.isdigit():
        index = int(choice) - 1
        if 0 <= index < len(files):
            file_name = files[index][:-4]
            display_file_content(file_name)
        else:
            print("Invalid file number.")
    elif choice == "-help":
        help_command()
    elif choice == "-list":
        files[:] = display_files()
    elif choice == "-exit":
        exit()
    else:
        print("\nInvalid option.")

# ======================================================================================================================================= #

def main():
    cool_logo()
    login_prompt()
    files = display_files()
    while True:
        choice = input("\n> ")
        handle_choice(choice, files)

# ======================================================================================================================================= #

if __name__ == "__main__":
    main()

# ======================================================================================================================================= #

In what way doesn’t it work?

Is it complaining that it can’t find the key file?

If yes, that’s because the key file is not in the current working directory (folder).

A path such as "key.json" is a relative path, i.e. it’s relative to the current working directory, wherever that happens to be at the time.

It’s better to use full, absolute paths.

If you’re keeping the key file in the same folder as the script, you can get the path of the script with __file__ and the path of its folder with os.path.dirname(__file__), and then make the path to the key file with os.path.join(os.path.dirname(__file__), "key.json").

everything works except getpass, it doesnt hide my text in any way and "Enter password: " doesnt show up

Well, it works for me!

Try adding:

print(getpass.__file__)

after the import.

Does the path it prints point to the correct library file?

yes, it does

On what OS are you and how are you running python?

windows 10 and through pycharm