GrahamMThomas / MapleAITrainer

Uses screen captures, OCR, and Reinforcement Learning to optimize training on a specific map in Maplestory
17 stars 0 forks source link

WinError 126 #2

Open bartotti opened 1 month ago

bartotti commented 1 month ago

Traceback (most recent call last): File "C:\Users\10232021\PycharmProjects\MapleAITrainer\run_latest.py", line 4, in from stable_baselines3 import PPO File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3__init.py", line 3, in from stable_baselines3.a2c import A2C File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\a2c\init.py", line 1, in from stable_baselines3.a2c.a2c import A2C File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\a2c\a2c.py", line 3, in import torch as th File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\torch\init__.py", line 148, in raise err OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

I had tried: .\new_env\Scripts\activate install visual C++ Redistributable packages both x86 and x64 and reintrall PyTorch: pip uninstall torch and pip install torch and double check that the fbgemm.dll was in lib folder pip install stable-baselines3 torch gymnasium

and none of these works any fixes ?

bartotti commented 1 month ago

So I some how fixed the issue of winError 126 by downgrading the pytorch verison to 1.13.0 and now I think the new issue is how to get the image processing operation to work

C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\Scripts\python.exe C:/Users/10232021/PycharmProjects/MapleAITrainer/train.py Creating new model! Using cpu device Wrapping the env in a VecTransposeImage. Wrapping the env in a VecTransposeImage. (0, 0, 4) Traceback (most recent call last): File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\PIL\ImageFile.py", line 547, in _save fh = fp.fileno() AttributeError: '_idat' object has no attribute 'fileno'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\10232021\PycharmProjects\MapleAITrainer\train.py", line 42, in main() File "C:\Users\10232021\PycharmProjects\MapleAITrainer\train.py", line 38, in main model.learn(total_timesteps=10000, callback=callback, reset_num_timesteps=False) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\ppo\ppo.py", line 315, in learn return super().learn( File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\common\on_policy_algorithm.py", line 287, in learn total_timesteps, callback = self._setup_learn( File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\common\base_class.py", line 423, in _setup_learn self._last_obs = self.env.reset() # type: ignore[assignment] File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\common\vec_env\vec_transpose.py", line 113, in reset observations = self.venv.reset() File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\common\vec_env\vec_frame_stack.py", line 46, in reset observation = self.venv.reset() File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\stable_baselines3\common\vec_env\dummy_vec_env.py", line 77, in reset obs, self.reset_infos[env_idx] = self.envs[env_idx].reset(seed=self._seeds[env_idx], *maybe_options) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\maplestory_live_env.py", line 143, in reset self.get_current_reward(raw_game_frame) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\maplestory_live_env.py", line 188, in get_current_reward exp_gained = self.get_exp_gained(raw_game_frame) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\maplestory_live_env.py", line 256, in get_exp_gained exp: str = pytesseract.image_to_string(exp_game_frame) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\pytesseract\pytesseract.py", line 423, in image_to_string return { File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\pytesseract\pytesseract.py", line 426, in Output.STRING: lambda: run_and_get_output(args), File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\pytesseract\pytesseract.py", line 277, in run_and_get_output with save(image) as (temp_name, input_filename): File "C:\Users\10232021\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in enter return next(self.gen) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\pytesseract\pytesseract.py", line 199, in save image.save(input_file_name, format=image.format) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\PIL\Image.py", line 2568, in save save_handler(self, fp, filename) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\PIL\PngImagePlugin.py", line 1431, in _save ImageFile._save(im, _idat(fp, chunk), [("zip", (0, 0) + im.size, 0, rawmode)]) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\PIL\ImageFile.py", line 551, in _save _encode_tile(im, fp, tile, bufsize, None, exc) File "C:\Users\10232021\PycharmProjects\MapleAITrainer\venv\lib\site-packages\PIL\ImageFile.py", line 562, in _encode_tile encoder.setimage(im.im, extents) SystemError: tile cannot extend outside image

Process finished with exit code 1

GrahamMThomas commented 1 month ago

I hardcoded the pixel values for locations of things on the screen because I was lazy. I have it in my todos to make it dynamic. But for now you'll probably have to tweak the values here:

https://github.com/GrahamMThomas/MapleAITrainer/blob/1199a52f9b320e38e69904458d59dd0137eff7bb/maplestory_live_env.py#L240

bartotti commented 1 month ago

I hardcoded the pixel values for locations of things on the screen because I was lazy. I have it in my todos to make it dynamic. But for now you'll probably have to tweak the values here:

https://github.com/GrahamMThomas/MapleAITrainer/blob/1199a52f9b320e38e69904458d59dd0137eff7bb/maplestory_live_env.py#L240

The pixcel values u mentioned is for the whole screen of the game ?