thomasroessl / FlowTutor

A graphical programming environment using flowcharts.
GNU Lesser General Public License v3.0
18 stars 2 forks source link

Error at startup #1

Closed DmitryKaverznev closed 5 months ago

DmitryKaverznev commented 5 months ago

When I run main.py an exception occurs:

C:\Users\User\AppData\Local\Temp\flowtutor-ihrks3_0
Traceback (most recent call last):
  File "c:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 59, in <module>
    main()
  File "c:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 55, in main
    start()
  File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched
  File "c:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 18, in start
    gui = GUI(2000, 2000)
  File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched
  File "C:\Users\User\Downloads\FlowTutor\.venv\lib\site-packages\flowtutor\gui\gui.py", line 202, in __init__
    self.parent_size = (int(self.settings_service.get_setting('width', '1000') or 1000),
  File "C:\Users\User\Downloads\FlowTutor\.venv\lib\site-packages\flowtutor\settings_service.py", line 28, in get_setting       
    with dbm.open(join(user_config_dir('flowtutor'), 'settings.db'), 'c') as db:
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\dbm\__init__.py", line 95, in open
    return mod.open(file, flag, mode)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\dbm\dumb.py", line 316, in open
    return _Database(file, mode, flag=flag)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\dbm\dumb.py", line 71, in __init__
    self._update(flag)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\dbm\dumb.py", line 105, in _update
    key, pos_and_siz_pair = _ast.literal_eval(line)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\ast.py", line 62, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 0

SyntaxError: unexpected EOF while parsing

There's something wrong with the line gui = GUI(2000, 2000) Or I didn't install the libraries correctly.

I didn't change the code. It worked before. I use Windows and Conda

DmitryKaverznev commented 5 months ago

What is wrong with:

        Path(user_config_dir('flowtutor')).mkdir(parents=True, exist_ok=True)
        with dbm.open(join(user_config_dir('flowtutor'), 'settings.db'), 'c') as db:
            if key not in db:
                return default
            else:
                val = db[key].decode()
                return val if val else default

Error:

unexpected EOF while parsing (<unknown>, line 0)
  File "C:\Users\User\Downloads\FlowTutor\src\flowtutor\settings_service.py", line 28, in get_setting
    with dbm.open(join(user_config_dir('flowtutor'), 'settings.db'), 'c') as db:
  File "C:\Users\User\Downloads\FlowTutor\src\flowtutor\gui\gui.py", line 202, in __init__
    self.parent_size = (int(self.settings_service.get_setting('width', '1000') or 1000),
  File "C:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 18, in start
    gui = GUI(2000, 2000)
  File "C:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 55, in main
    start()
  File "C:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 59, in <module>
    main()
SyntaxError: unexpected EOF while parsing (<unknown>, line 0)
thomasroessl commented 5 months ago

There was an error running FlowTutor with Python 3.12, becase of an incompatible dependency. I fixed this issue in version 0.11.0

The second problem seems to be associated with the file, where the settings are stored. Could you try running FlowTutor in a fresh virtual environment?

DmitryKaverznev commented 5 months ago

Thanks for the answer, here are the steps I take:

  1. Create a virtual environment conda (3.12)
  2. Install packages (python -m pip install flowtutor)
  3. Run main.py (src\flowtutor)
  4. I get the error:
    
    C:\Users\User\AppData\Local\Temp\flowtutor-uvcfi2m3
    Traceback (most recent call last):
    File "c:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 59, in <module>
    main()
    File "c:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 55, in main
    start()
    File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched
    File "c:\Users\User\Downloads\FlowTutor\src\flowtutor\main.py", line 18, in start
    gui = GUI(2000, 2000)
          ^^^^^^^^^^^^^^^
    File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\site-packages\flowtutor\gui\gui.py", line 202, in __init__  
    self.parent_size = (int(self.settings_service.get_setting('width', '1000') or 1000),
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\site-packages\flowtutor\settings_service.py", line 28, in get_setting
    with dbm.open(join(user_config_dir('flowtutor'), 'settings.db'), 'c') as db:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\dbm\__init__.py", line 95, in open
    return mod.open(file, flag, mode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\dbm\dumb.py", line 317, in open
    return _Database(file, mode, flag=flag)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\dbm\dumb.py", line 72, in __init__
    self._update(flag)
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\dbm\dumb.py", line 106, in _update
    key, pos_and_siz_pair = _ast.literal_eval(line)
                            ^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\ast.py", line 66, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\User\Downloads\FlowTutor\.conda\Lib\ast.py", line 52, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<unknown>", line 0

SyntaxError: invalid syntax


The Traceback shows that something is wrong in the gui class. It is not very different from the previous one, the interpreter does not like it:
     self.parent_size = (int(self.settings_service.get_setting('width', '1000') or 1000),
                         int(self.settings_service.get_setting('height', '1000') or 1000))

Maybe it's the new packages?
thomasroessl commented 5 months ago

Thanks for the feedback.

If you install it with conda like your step 2, there should be an exe somewhere. I installed conda on my system to try it out and for me it was located at C:\Users\User\AppData\Roaming\Python\Python312\Scripts\flowtutor.exe Depending on your setup, it might get installed to a location in your PATH. In that case you can just run it directly from the terminal with the command "flowtutor".

You shouldn't have to manually run main.py in either case.

From the error message I think maybe the file where the settings are stored got corrupted on your system somehow. There should be a directory C:\Users\User\AppData\Local\flowtutor\flowtutor which contains a few files. Could you try deleting everything from this directory and see if that helps?

DmitryKaverznev commented 5 months ago

Thank you, I realized that there is no need to rebuild the application and run main.py. Now there is an application for visualizing algorithms