will7200 / Yugioh-bot

Bot for Yugioh Duel Links via Nox and Steam
MIT License
58 stars 9 forks source link

Cannot read image conversion from file, missing pywin32 in dependency list #48

Closed trwnh closed 6 years ago

trwnh commented 6 years ago
$ python main.py bot -s
C:\Users\trwnh\AppData\Local\Programs\Python\Python36-32\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "main.py", line 143, in <module>
    cli()
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "main.py", line 91, in bot
    dlRuntime = setup_runtime(uconfig)
  File "main.py", line 38, in setup_runtime
    from bot.providers import get_provider
  File "D:\Programs\Yugioh-bot\bot\providers\__init__.py", line 15, in <module>
    from bot.providers.nox import Nox
  File "D:\Programs\Yugioh-bot\bot\providers\nox\__init__.py", line 1, in <module>
    from .nox import Nox
  File "D:\Programs\Yugioh-bot\bot\providers\nox\nox.py", line 6, in <module>
    import win32gui
ModuleNotFoundError: No module named 'win32gui'

The issue is not because win32gui is not installed:

$ python -m pip install win32gui
Requirement already satisfied: win32gui in c:\...\python\python36-32\lib\site-packages
Requirement already satisfied: win32core in c:\...\python\python36-32\lib\site-packages (from win32gui)
You are using pip version 9.0.1, however version 9.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Manually commenting out line 15 in bot\providers__init__.py (from bot.providers.nox import Nox) and all other lines mentioning nox, and replacing the if/elif with a single if now results in a different error:

$ python main.py bot -s
...\Python\Python36-32\lib\site-packages\h5py\__init__.py:36:
 FutureWarning: Conversion of the second argument of
 issubdtype from `float` to `np.floating` is deprecated.
 In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "main.py", line 143, in <module>
    cli()
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "...\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "main.py", line 91, in bot
    dlRuntime = setup_runtime(uconfig)
  File "main.py", line 38, in setup_runtime
    from bot.providers import get_provider
  File "D:\Programs\Yugioh-bot\bot\providers\__init__.py", line 16, in <module>
    from bot.providers.steam import Steam
  File "D:\Programs\Yugioh-bot\bot\providers\steam\__init__.py", line 1, in <module>
    from .steam import Steam
  File "D:\Programs\Yugioh-bot\bot\providers\steam\steam.py", line 5, in <module>
    import win32api
ModuleNotFoundError: No module named 'win32api'

Some googling reveals that win32api is part of pywin32, which was NOT listed as one of the requirements in the text files and requires manually running python -m pip install pywin32, and now it seemingly works, except... the bot doesn't know how to do anything. Here's the log of the run:

$ python main.py bot -s
C:\...\Python\Python36-32\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
2018-03-21 14:04 - INFO - apscheduler.scheduler - Scheduler started
2018-03-21 14:04 - DEBUG - bot - Value next_run_at modified to 2018-03-21 14:04:35.889579
2018-03-21 14:04 - INFO - apscheduler.scheduler - Added job "DuelLinkRunTime.main.<locals>.in_main" to job store "default"
2018-03-21 14:04 - INFO - bot - Next run at 2018-03-21T14:04:35.889579
2018-03-21 14:04 - INFO - apscheduler.executors.default - Running job "DuelLinkRunTime.main.<locals>.in_main (trigger: date[2018-03-21 14:04:35 CDT], next run at: 2018-03-21 14:04:35 CDT)" (scheduled at 2018-03-21 14:04:35.889579-05:00)
2018-03-21 14:04 - INFO - apscheduler.scheduler - Removed job cron_main_at_2018-03-21T14:04:35.889579
2018-03-21 14:04 - DEBUG - bot - Value last_run_at modified to 2018-03-21 14:04:35.898780
2018-03-21 14:04 - INFO - bot.provider.Steam - Passing Through Start Screen
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:04 - INFO - bot - starting auto play through
2018-03-21 14:04 - INFO - bot.provider.Steam - starting auto run through
2018-03-21 14:04 - DEBUG - bot.provider.Steam - Run through 1
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:04 - DEBUG - bot.provider.Steam - Tapping at location (1119,455)
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:04 - DEBUG - bot.provider.Steam - Tapping at location (896,810)
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOKING FOR CLOSE BUTTON, HIGH CORRERLATION
2018-03-21 14:04 - INFO - bot.provider.Steam - NPC Battle Mode,Points: (896,810) at location: (1), message: failure/Close-Button
2018-03-21 14:04 - DEBUG - bot.provider.Steam - Tapping at location (805,824)
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOKING FOR CLOSE BUTTON, HIGH CORRERLATION
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOK FOR WORD 'OK', HIGH CORRERLATION
2018-03-21 14:04 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:04 - DEBUG - bot.provider.Steam - Tapping at location (828,780)
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOKING FOR CLOSE BUTTON, HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOK FOR WORD 'OK', HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - Tapping at location (784,714)
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOKING FOR CLOSE BUTTON, HIGH CORRERLATION
2018-03-21 14:05 - INFO - bot.provider.Steam - NPC Battle Mode,Points: (784,714) at location: (1), message: failure/Close-Button
2018-03-21 14:05 - DEBUG - bot.provider.Steam - Tapping at location (733,545)
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOKING FOR CLOSE BUTTON, HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOK FOR WORD 'OK', HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - LOOKING FOR BACK BUTTON, HIGH CORRERLATION
2018-03-21 14:05 - DEBUG - bot.provider.Steam - Tapping at location (878,714)
2018-03-21 14:05 - DEBUG - bot.provider.Steam - Tapping at location (614,825)
2018-03-21 14:05 - INFO - bot.provider.Steam - Verifying battle
2018-03-21 14:05 - DEBUG - bot - <class 'FileNotFoundError'> duel_links_runtime.py 375
2018-03-21 14:05 - DEBUG - bot - Traceback (most recent call last):
  File "D:\Programs\Yugioh-bot\bot\duel_links_runtime.py", line 375, in in_main
    self.determine_playthrough(provider)
  File "D:\Programs\Yugioh-bot\bot\duel_links_runtime.py", line 334, in determine_playthrough
    provider.auto()
  File "D:\Programs\Yugioh-bot\bot\providers\provider.py", line 55, in auto
    raise e
  File "D:\Programs\Yugioh-bot\bot\providers\provider.py", line 52, in auto
    self.scan()
  File "D:\Programs\Yugioh-bot\bot\providers\steam\steam.py", line 226, in scan
    battle, version = self.verify_battle()
  File "D:\Programs\Yugioh-bot\bot\providers\provider.py", line 164, in verify_battle
    word = self.img_to_string(img, alpha_numeric).lower()
  File "D:\Programs\Yugioh-bot\bot\providers\provider.py", line 225, in img_to_string
    with open("tmp\\ocr.txt") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'tmp\\ocr.txt'

2018-03-21 14:05 - DEBUG - bot - Value next_run_at modified to 2018-03-21 18:05:35.412186
2018-03-21 14:05 - INFO - apscheduler.scheduler - Added job "DuelLinkRunTime.main.<locals>.in_main" to job store "default"
2018-03-21 14:05 - INFO - apscheduler.executors.default - Job "DuelLinkRunTime.main.<locals>.in_main (trigger: date[2018-03-21 14:04:35 CDT], next run at: 2018-03-21 14:04:35 CDT)" executed successfully

I'm completely unsure of what to do at this point.

will7200 commented 6 years ago

This boils down to two things, either tesseract is not properly installed in specified location or tesseract is not installed. The install script points to the directory it should have been installed into. Reference #21 and #41 as they are similar issues.

will7200 commented 6 years ago

I made the import structure to import all bot providers, it just happened that the Nox provider was the first one on the list to give an error, so that is not an issue.

will7200 commented 6 years ago

Added pywin32 reference in 42e1273f528f64db7eda904f8984575b769e21ed

will7200 commented 6 years ago

Closing due to no response. Open again if is needed.