VoxelCubes / PanelCleaner

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

Issue with docopt #12

Closed bug-assassin closed 1 year ago

bug-assassin commented 1 year ago

When I try to run pcleaner (pcleaner --help), I get the following docopt related error message: 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\Desktop\python\Scripts\pcleaner.exe\__main__.py", line 7, in <module> File "C:\Users\myuser\Desktop\python\Lib\site-packages\pcleaner\main.py", line 142, in main args = docopt(__doc__, version=f"{__version__}", more_magic=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\myuser\Desktop\python\Lib\site-packages\docopt\__init__.py", line 877, in docopt assert instr.opname.startswith("CALL_")

Environment Windows 10 (no WSL) Python 3.11.3 docopt 0.6.2 pcleaner 1.7.3 python-magic-bin 0.4.14 (can't use python-magic because of this issue)

The python version of docopt doesn't seem to be maintained anymore. The latest release is from 2014 and the last commit is from 2018 so the issue might be related to my python version.

I'm using this workaround for now.

line 116 from docopt import docopt

line 142 args = docopt(__doc__, version=f"Panel Cleaner {__version__}")

EDIT 2023-05-29: Also change pcleaner/structures.py

Replace lines 78-80 below:
metadata = magic.from_file(self.image_path)
size_str = re.search(r"(\d+) x (\d+)", metadata).groups()
self._image_size = (int(size_str[0]), int(size_str[1]))

With:
self._image_size = Image.open(self.image_path).size
VoxelCubes commented 1 year ago

The version of docopt that pcleaner uses is actually docopt-ng, the fork that's being maintained by jazzband. Maybe you already had docopt installed, hence pip not upgrading to docopt-ng?

bug-assassin commented 1 year ago

The version of docopt that pcleaner uses is actually docopt-ng, the fork that's being maintained by jazzband. Maybe you already had docopt installed, hence pip not upgrading to docopt-ng?

Hmm, I had both docopt and docopt-ng installed. After removing docopt and reinstalling docopt-ng, I still get the same error so I think the problem is actually python-magic-bin because the workaround in my first post still works.

python-magic-bin 0.4.14 (the latest version) is from 2017 so I probably need to get python-magic installed properly but the workaround is good enough for me.

techicode commented 1 year ago

thanks for the workaround. The same issue in my old laptop (without a dedicated gpu), but after your workaround works just fine.

Environment Arch Linux Python 3.11.3 docopt-ng 0.8.1 docopt (not installed) pcleaner 1.7.3 python-magic 0.4.27 python-magic-bin (not installed)

VoxelCubes commented 1 year ago

I think I fixed the issue by removing the dependence on the magic docopt, instead using the backwards-compatible regular docopt. So it works with both versions of docopt now, without having this conflicting version problem if you installed the other docopt previously.