Skip to content

Python os Modul path bug (Windows 11, Python Version 3.12.5) #123810

@kingconic1

Description

@kingconic1

Bug report

Bug description:

#Console for evrything ;)
import os


def try_to_get_steam_path():
    #geht alle möglichen laufwerke durch um den steam path zu finden
    laufwerke = ["C:", "D:", "E:", "F:"]
    try:
        for lauf in laufwerke:
            try:
                val = os.listdir(lauf)
                if "SteamLibrary" in val:
                    print("steam found in Disk:", lauf)
                    path = lauf + "\SteamLibrary" + "\steamapps" + "\common"
                    print("Path:", path)
            except Exception as e:
                print(f"Error accessing {lauf}: {e}")
                
    except Exception as e:
        print(f"Error accessing {lauf}: {e}")

    
    #path = "try"
    return path


def steam_games_info(steam_path):
    # can run if this path was founded "D:\SteamLibrary\steamapps\common"
    a = os.listdir(steam_path)
    b = 0
    for i in a:
        b +=1
    print(f"You have {b} Games")
    print(a)
#steam_games_info()

steam_path = ""


def enter_steam_game():
    global steam_path
    steam_path = try_to_get_steam_path()
    games = os.listdir(steam_path)
    print(games)
    for game in games:
        try:
            steam_path = steam_path + r"\" + f"{game}"
            os.listdir(steam_path)
        except Exception as e:
            print(e)

        pass


#funktioniert also das die eine funktion den steam path bekommt und ihn dann erfolgreich der anderen funktion übermittelt

def main():
    global steam_path
    while True:
        com = input("Command: ")
        if com == "!Steam" or com == "!steam":
            steam_games_info(steam_path)
        elif com == "bye":
            break
            pass
        elif com == "deb":
            steam_path = try_to_get_steam_path()
            print()
            print(steam_path)
            #steam_games_info(steam_path)
        elif com == "deb2":
            enter_steam_game()
        else:
            print("Error")
main()

Idle output

[WinError 3] Das System kann den angegebenen Pfad nicht finden: D:\\SteamLibrary\\steamapps\\common\\

the system cant find the folder because and makes out of the normal path an path with "//" and idk why

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions