VoxelCubes / PanelCleaner

An AI-powered tool to clean manga panels.
GNU General Public License v3.0
241 stars 18 forks source link

[Windows] "Could not open theme file: breeze-dark" error after upgrading through pip #88

Closed arihid closed 6 months ago

arihid commented 6 months ago

Describe the bug I noticed that there's an update for the app after I accessed this repo. First, I excecuted pip install pcleaner and returned Requirement already satisfied on all the packages, because of course it was. Then I excecuted pip install -U pcleaner and it updated successfully. When I try to run it both cli cleaner or gui pcleaner-gui, it returns:

D:\<sanitized>\Tools>pcleaner
qt.svg: Cannot open file ':/custom_icons/dark/mask_denoised.svg', because: Input/output error
qt.svg: Cannot open file ':/custom_icons/dark/mask_denoised.svg', because: Input/output error
2024-05-02 00:54:13.337 | ERROR    | pcleaner.gui.file_table:__init__:105 - Failed to load icon mask_denoised.svg for dark theme.
qt.svg: Cannot open file ':/custom_icons/light/mask_denoised.svg', because: Input/output error
qt.svg: Cannot open file ':/custom_icons/light/mask_denoised.svg', because: Input/output error
2024-05-02 00:54:13.338 | ERROR    | pcleaner.gui.file_table:__init__:105 - Failed to load icon mask_denoised.svg for light theme.
2024-05-02 00:54:13.341 | WARNING  | pcleaner.gui.image_tab:update_tabs:122 - Updating tabs with step None.
2024-05-02 00:54:13.902 | CRITICAL | pcleaner.gui.launcher:launch:124 - Failed to initialize the main window.
Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code

  File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python312\Scripts\pcleaner.exe\__main__.py", line 7, in <module>
    sys.exit(main())
    │   │    └ <function main at 0x000002571422C680>
    │   └ <built-in function exit>
    └ <module 'sys' (built-in)>

  File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\main.py", line 276, in main
    gui.launch(args.image_path, args.debug)
    │   │      │                └ {'--both': False,
    │   │      │                   '--cache-masks': False,
    │   │      │                   '--cpu': False,
    │   │      │                   '--csv': False,
    │   │      │                   '--cuda': False,
    │   │      │                   '--debug': False,
    │   │      │                   '--extract...
    │   │      └ {'--both': False,
    │   │         '--cache-masks': False,
    │   │         '--cpu': False,
    │   │         '--csv': False,
    │   │         '--cuda': False,
    │   │         '--debug': False,
    │   │         '--extract...
    │   └ <function launch at 0x000002574DD11B20>
    └ <module 'pcleaner.gui.launcher' from 'C:\\Users\\<myuser>\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pcle...
> File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\launcher.py", line 120, in launch
    window = MainWindow(config, files_to_open, debug)
             │          │       │              └ False
             │          │       └ []
             │          └ Config(locale=None, current_profile=Profile(general=GeneralConfig(notes='', preferred_file_type=None, preferred_mask_file_typ...
             └ <class 'pcleaner.gui.mainwindow_driver.MainWindow'>
  File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\mainwindow_driver.py", line 121, in __init__
    self.load_config_theme()
    │    └ <function MainWindow.load_config_theme at 0x000002574DCFEF20>
    └ <pcleaner.gui.mainwindow_driver.MainWindow(0x2574775ed50, name="MainWindow") at 0x000002574DD44AC0>
  File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\mainwindow_driver.py", line 140, in load_config_theme
    self.set_theme(theme)
    │    │         └ 'breeze-dark'
    │    └ <function MainWindow.set_theme at 0x000002574DCFEFC0>
    └ <pcleaner.gui.mainwindow_driver.MainWindow(0x2574775ed50, name="MainWindow") at 0x000002574DD44AC0>
  File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\mainwindow_driver.py", line 157, in set_theme
    palette = gu.load_color_palette(theme)
              │  │                  └ 'breeze-dark'
              │  └ <function load_color_palette at 0x0000025748648F40>
              └ <module 'pcleaner.gui.gui_utils' from 'C:\\Users\\<myuser>\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pcl...
  File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\gui_utils.py", line 269, in load_color_palette
    raise ValueError(f"Could not open theme file: {theme}")
                                                   └ 'breeze-dark'

ValueError: Could not open theme file: breeze-dark

In short: it can't load a theme file.

To Reproduce Steps to reproduce the behavior:

  1. Use Windows 11
  2. Run terminal and excecute pip install -U pcleaner
  3. Run pcleaner from that terminal
  4. See log above

Expected behavior Well, it should open main pcleaner gui as it does with my previous install.

Session Log Log is attached above.

GH6 commented 6 months ago

I have this problem too. I can't find the dark/light theme when I run it with cmd, so I run it with VS2022, and I get the same problem as above.

VoxelCubes commented 6 months ago

What version of PySide6 do you have installed? It's likely that they broke their resource file format on windows again. Try downgrading the PySide6 package specifically, or use the exe.

I've confirmed it still works with PySide 6.6.0 on Windows (10).

VoxelCubes commented 6 months ago

It seems likely I'll have to include a separate resource bundle for windows, which isn't how this is supposed to work. Damnit Qt.

arihid commented 6 months ago

What version of PySide6 do you have installed? It's likely that they broke their resource file format on windows again. Try downgrading the PySide6 package specifically, or use the exe.

I've confirmed it still works with PySide 6.6.0 on Windows (10).

I was using PySide 6.6.2 on Python 3.12. Apparently, only PySide 6.6.0 onwards are available for me, so I combed through all the versions, and have no luck so far. I'm currently trying to figure out how to use pyenv to get this up and running.

And... "Again"?

VoxelCubes commented 6 months ago

Yeah, I encountered the issue once when building the exe. Before that it didn't have a problem with the cross-platform resource bundle. I'm looking into this right now.

VoxelCubes commented 6 months ago

For reference, this is my package list in my windows (virtual) machine: altgraph 0.17.4
attrs 23.1.0
certifi 2023.7.22
charset-normalizer 3.3.2
colorama 0.4.6
ConfigUpdater 3.1.1 decorator 5.1.1 dictdiffer 0.9.0 docopt-ng 0.9.0 filelock 3.13.1 fire 0.5.0 fsspec 2023.10.0 fugashi 1.3.0 huggingface-hub 0.17.3 humanfriendly 10.0 idna 3.4 jaconv 0.3.4 Jinja2 3.1.2 loguru 0.7.2 logzero 1.7.0 manga-ocr 0.1.11 MarkupSafe 2.1.3 mpmath 1.3.0 natsort 8.4.0 networkx 3.2.1 numpy 1.26.1 opencv-python 4.8.1.78 packaging 23.2 pefile 2023.2.7 Pillow 9.5.0 pip 22.3.1 prettytable 3.9.0 psutil 5.9.8 pyclipper 1.3.0.post5 pyinstaller 6.1.0 pyinstaller-hooks-contrib 2023.10 pyperclip 1.8.2 pypiwin32 223 pyreadline3 3.4.1 PySide6 6.6.0 PySide6-Addons 6.6.0 PySide6-Essentials 6.6.0 python-magic-bin 0.4.14 pyuac 0.0.3 pywin32 306 pywin32-ctypes 0.2.2 PyYAML 6.0.1 regex 2023.10.3 requests 2.31.0 safetensors 0.4.0 scipy 1.11.3 setuptools 65.5.1 shapely 2.0.2 shiboken6 6.6.0 simple-lama-inpainting 0.1.2 six 1.16.0 sympy 1.12 tee 0.0.3 termcolor 2.3.0 tifffile 2023.9.26 tokenizers 0.14.1 torch 2.1.0 torchvision 0.16.0 tqdm 4.66.1 transformers 4.35.0 typing_extensions 4.8.0 unidic-lite 1.0.8 urllib3 2.0.7 wcwidth 0.2.9 wheel 0.38.4 win10toast 0.9 win32-setctime 1.1.0 xdg 6.0.0

You may be missing some of these, but that's because they are for development.

In particular though, PySide6 also has the addons and essentials packages. Those might have different versions now.

arihid commented 6 months ago

I set up pyenv for version 3.10.5, and combed through 6.2.0, 6.3.0, 6.4.0, 6.5.0, 6.5.3, and still no luck.

I've compared my installed package to yours, and I think that the differences aren't really needed for my use case.

VoxelCubes commented 6 months ago

Oh, at the very least you can go into your config file in %APPDATA% and delete the entry specifying the color theme. But that won't help if it fails to load the icons too. That should get it working again. Or wait for an update that I'm working on right now. I managed to replicate and fix the error, though I guess I will go ahead and make windows specific resource bundles.

VoxelCubes commented 6 months ago

All right, hotfix update 2.6.2 has now fixed the issue.

For some cursed reason the buttons on the first page of the profile options has an odd dark mode applied to it when not using the system theme, affecting Windows only. This wasn't the case with the old PySide version, and only affects the first set of options (when reversing the order in which they are loaded, then inpainting is the one affected instead of general). I didn't manage to fix it and hope a new version of PySide will undo that regression.

Thanks for reporting it!

P.S. good luck with scanlations :) I'd be interested in hearing how well the inpainting is working, if you've tried it.

arihid commented 6 months ago

The program is now runs as expected. Thank you very much!

That Inpainting feature seems interesting... Yeah, I'm facing problems with basically what Inpainting trying to achieve. I'll definitely try it out!

GH6 commented 6 months ago

After the update, this issue was fixed for me too!