AdriaGual / pokemon-pocket-bot

A computer vision bot made with OpenCV, OCR and ADB.
23 stars 1 forks source link

Error after full setup #1

Closed TerpToke closed 2 weeks ago

TerpToke commented 2 weeks ago

After starting the bot I get this error, any advice?:

"Exception in thread Thread-1 (connect_and_run): Traceback (most recent call last): File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner self.run() File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run self._target(*self._args, self._kwargs) File "C:\Users\camer\Downloads\pokemon-pocket-bot-main\pokemon-pocket-bot-main\bot.py", line 52, in connect_and_run connect_to_emulator(self.app_state.emulator_name) File "C:\Users\camer\Downloads\pokemon-pocket-bot-main\pokemon-pocket-bot-main\adb_utils.py", line 8, in connect_to_emulator subprocess.run(["adb", "connect", emulator_name]) File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run with Popen(*popenargs, *kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1462, in _execute_child args = list2cmdline(args) ^^^^^^^^^^^^^^^^^^ File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 608, in list2cmdline for arg in map(os.fsdecode, seq): File "", line 859, in fsdecode TypeError: expected str, bytes or os.PathLike object, not NoneType" Exception in thread Thread-1 (connect_and_run): Traceback (most recent call last): File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner self.run() File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run self._target(self._args, self._kwargs) File "C:\Users\camer\Downloads\pokemon-pocket-bot-main\pokemon-pocket-bot-main\bot.py", line 52, in connect_and_run connect_to_emulator(self.app_state.emulator_name) File "C:\Users\camer\Downloads\pokemon-pocket-bot-main\pokemon-pocket-bot-main\adb_utils.py", line 8, in connect_to_emulator subprocess.run(["adb", "connect", emulator_name]) File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1462, in _execute_child args = list2cmdline(args) ^^^^^^^^^^^^^^^^^^ File "C:\Users\camer\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 608, in list2cmdline for arg in map(os.fsdecode, seq): File "", line 859, in fsdecode TypeError: expected str, bytes or os.PathLike object, not NoneType

AdriaGual commented 2 weeks ago

Hey @TerpToke !

I did an update in order to don't need to update the configs.txt manually, just do a pull of the code and try again!

For more information: This happens because on the configs.txt file you don't have set up the emulator name, you can know the emulator name by running a adb devices.

321098123 commented 2 weeks ago

I resolved this issue by adding the shell=True argument to all subprocess.run commands and registering LDPlayer's ADB in the system environment variables.

TerpToke commented 2 weeks ago

Thanks for getting back to me @AdriaGual !!!

The UI populates perfectly fine, the code doesn't pop up until I hit "Start Bot".

I have my emulator name, I'm just not exactly sure where to put it. "emulator-5554"

Thank you for your work and support!

After updating to your latest pull I am unfortunately facing the same error.

TerpToke commented 2 weeks ago

Hello!

Yes there is a config! :)

The UI opens!

Path is chosen correctly!

On Mon, Nov 4, 2024 at 3:47 AM Adrià Gual @.***> wrote:

Hey! Just a bunch of ideas I have.

Does the UI open?

And did you chose the path to your emulator?

There should be a configs.txt file generated in the project, is there config?

— Reply to this email directly, view it on GitHub https://github.com/AdriaGual/pokemon-pocket-bot/issues/1#issuecomment-2454119020, or unsubscribe https://github.com/notifications/unsubscribe-auth/APDTN6LME63CWIHY322C7ZTZ64YDHAVCNFSM6AAAAABRDU74HGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJUGEYTSMBSGA . You are receiving this because you authored the thread.Message ID: @.***>

AdriaGual commented 2 weeks ago

@TerpToke If you already have the emulator name, you can open the configs.txt file and add:

path = "C:/LDPlayer/LDPlayer9"
emulator = "emulator-5554"
TerpToke commented 2 weeks ago

image_2024-11-04_191901781 @AdriaGual Sadly it seems I have the same error after adding that line to my configs.txt I even double checked my emulator name.

C:\LDPlayer\LDPlayer9>adb devices List of devices attached emulator-5554 device

It may or may not help but I'm using a specific version of LDPlayer that was posted by the official "LDPlayer" Reddit profile to enable vulkan for Pokemon TCGP. The versions posted on their website did not work for this game for me. "https://res.ldrescdn.com/download/package/LDPlayer_9.1.25.1.exe" "https://www.reddit.com/r/LDPlayerEmulator/comments/1gfmh0k/cant_play_pokemon_tcg_pocket_on_ldplayer/"

TerpToke commented 2 weeks ago

I resolved this issue by adding the shell=True argument to all subprocess.run commands and registering LDPlayer's ADB in the system environment variables.

Thanks for the tip @321098123 ! After going into subprocess.py and changing all shell=False to shell=True, along with adding LDPlayer's ADB into System Variables. It now seems like the bot wants to work but cmd states:

"'adb' is not recognized as an internal or external command, operable program or batch file."

I am not entirely sure what the issue may be? (I took the screenshot right after trying it in battle)

Thank you for everyone's help. I'm very determined to get this to work! image_2024-11-05_015837874

image_2024-11-05_020156214

321098123 commented 2 weeks ago

@TerpToke Does this work properly, by any chance? The image search for bench cards still isn't working correctly for me https://github.com/AdriaGual/pokemon-pocket-bot/issues/2#issue-2634009027

AdriaGual commented 2 weeks ago

@TerpToke You'll get it for sure, don't worry!

So, you can try to add the path to the adb (C:\LDPlayer\LDPlayer9) to the system variable called Path. image

Also restart the computer after that.

Another thing I would do is to go to the root of the project folder and open a cmd there to see if I can run a adb devices there.

AdriaGual commented 2 weeks ago

@321098123 You tried changing the variable mentioned here? https://github.com/AdriaGual/pokemon-pocket-bot/issues/2#issuecomment-2455893904

Just in case, the pictures that the bot will take will be from the hand (it does a long press and then takes the screenshot), so just let the bot run, it'll save all the hand cards and then you choose the ones you need.

Hope it helps!

TerpToke commented 2 weeks ago

@TerpToke You'll get it for sure, don't worry!

So, you can try to add the path to the adb (C:\LDPlayer\LDPlayer9) to the system variable called Path. image

Also restart the computer after that.

Another thing I would do is to go to the root of the project folder and open a cmd there to see if I can run a adb devices there.

That fixed it right up! I didn't realize I hadn't added it directly to Path. Going to start messing around with it now! Thank you kindly for your work and support. Keep it up! <3