[Python] AttributeError: partially initialized module 'threading' has no attribute 'RLock'...

Discussão em 'Python' iniciado por Stack, Setembro 23, 2024.

  1. Stack

    Stack Membro Participativo

    Sorry to ask but I'm a newbie in Python and just doing a presonal project.

    This is my folder structure

    Main Folder Inside Main folder I only have setup_log.txt and setup_tool.py. Other than that none.

    Here's the code where I used the threading

    import threading
    class Spinner:
    def __init__(self, message="Processing"):
    self.spinner = itertools.cycle(['|', '/', '-', '\\'])
    self.stop_running = threading.Event()
    self.message = message
    self.thread = threading.Thread(target=self.init_spin)

    def init_spin(self):
    while not self.stop_running.is_set():
    sys.stdout.write(f'\r{self.message} {next(self.spinner)}')
    sys.stdout.flush()
    time.sleep(0.1)
    sys.stdout.write('\r' + ' ' * len(self.message) + ' \r') # Clear the line

    def start(self):
    self.thread.start()

    def stop(self):
    self.stop_running.set()
    self.thread.join()

    Now the error

    When I run python using 'python setup_tools.py' it returns this error
    **Traceback (most recent call last):
    File "C:\Users\XXXXXXX\Desktop\2024\asc_developer_V2\setup_tool.py", line 2, in <module>
    import subprocess
    File "C:\Users\XXXXXXX\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 51, in <module>
    import threading
    File "C:\Users\XXXXXXX\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 3, in <module>
    import logging
    File "C:\Users\XXXXXXX\AppData\Local\Programs\Python\Python312\Lib\logging\__init__.py", line 232, in <module>
    _lock = threading.RLock()
    ^^^^^^^^^^^^^^^
    AttributeError: partially initialized module 'threading' has no attribute 'RLock' (most likely due to a circular import)**

    Continue reading...

Compartilhe esta Página