android_env icon indicating copy to clipboard operation
android_env copied to clipboard

AndroidEnv quits because of an unexpected keyword argument 'use_poll'

Open s-gv opened this issue 3 years ago • 3 comments

I tried running run_random_agent.py and got a crash right after the virtual device booted. What might be the problem? Does AndroidEnv need a newer version of Python than 3.6?

I0908 16:13:04.342051 140434626111232 coordinator.py:175] Simulator launch attempt 1 of 3
I0908 16:13:04.342184 140434626111232 emulator_launcher.py:87] Booting the emulator [/home/sagar/Android/Sdk/emulator/emulator]
I0908 16:13:04.342311 140434626111232 emulator_launcher.py:107] extra_env_vars: {'ANDROID_HOME': '', 'ANDROID_SDK_ROOT': '/home/sagar/Android/Sdk', 'ANDROID_AVD_HOME': '/home/sagar/.android/avd', 'ANDROID_EMULATOR_KVM_DEVICE': '/dev/kvm', 'ANDROID_ADB_SERVER_PORT': '5037', 'LD_LIBRARY_PATH': '/home/sagar/Android/Sdk/emulator/lib64/x11/:/home/sagar/Android/Sdk/emulator/lib64/qt/lib/:/home/sagar/Android/Sdk/emulator/lib64/gles_swiftshader/:/home/sagar/Android/Sdk/emulator/lib64/', 'QT_DEBUG_PLUGINS': '1', 'QT_XKB_CONFIG_ROOT': '/home/sagar/Android/Sdk/emulator/qt_config/'}
I0908 16:13:04.342589 140434626111232 emulator_launcher.py:123] Emulator launch command: /home/sagar/Android/Sdk/emulator/emulator -no-snapshot -gpu swiftshader_indirect -no-audio -verbose -avd pixel4 -ports 19811,15342
I0908 16:13:04.345738 140434626111232 emulator_launcher.py:136] Waiting for boot for 300.0 seconds...
I0908 16:13:33.728062 140434626111232 emulator_launcher.py:138] Emulator log matched: b'emulator: INFO: boot completed'
I0908 16:13:33.728239 140434626111232 emulator_launcher.py:146] Done booting the emulator (in 29.385461 seconds).
I0908 16:13:33.728819 140434626111232 emulator_console.py:264] Connecting to Emulator console on port 19811...
I0908 16:13:33.730707 140434626111232 emulator_console.py:279] Done connecting to Emulator console on port 19811.
I0908 16:13:33.730814 140434626111232 emulator_console.py:282] Authenticating to console.
I0908 16:13:33.784988 140434626111232 adb_controller.py:458] Fetching screen dimensions...
I0908 16:13:33.785164 140434626111232 adb_controller.py:184] Initialising ADB shell with command: /home/sagar/Android/Sdk/platform-tools/adb -P 5037 -s emulator-15341 shell
I0908 16:13:33.785252 140434626111232 adb_controller.py:190] Spawning ADB shell...
Traceback (most recent call last):
  File "run_random_agent.py", line 82, in <module>
    app.run(main)
  File "/home/sagar/.local/lib/python3.6/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/sagar/.local/lib/python3.6/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "run_random_agent.py", line 54, in main
    run_headless=False) as env:
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/loader.py", line 73, in load
    coordinator = coordinator_lib.Coordinator(simulator, task_manager)
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/coordinator.py", line 88, in __init__
    self._restart_simulator()
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/coordinator.py", line 181, in _restart_simulator
    self._simulator.launch()
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/base_simulator.py", line 136, in launch
    self._post_launch_setup()
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/emulator_simulator.py", line 117, in _post_launch_setup
    super()._post_launch_setup()
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/base_simulator.py", line 151, in _post_launch_setup
    self._adb_controller.get_screen_dimensions())
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/adb_controller.py", line 459, in get_screen_dimensions
    self._wait_for_device(timeout=timeout)
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/adb_controller.py", line 234, in _wait_for_device
    ready = self._check_device_is_ready(timeout=timeout)
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/adb_controller.py", line 247, in _check_device_is_ready
    ['shell', 'service', 'check', service], timeout=timeout)
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/adb_controller.py", line 116, in _execute_command
    adb_output = self._execute_shell_command(args[1:], timeout=timeout)
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/adb_controller.py", line 149, in _execute_shell_command
    self._init_shell(timeout=timeout)
  File "/home/sagar/.local/lib/python3.6/site-packages/android_env/components/adb_controller.py", line 191, in _init_shell
    self._adb_shell = pexpect.spawn(command, use_poll=True, timeout=timeout)
TypeError: __init__() got an unexpected keyword argument 'use_poll'
I0908 16:13:33.866050 140434626111232 emulator_launcher.py:156] Killing the emulator process...
I0908 16:13:33.972082 140434626111232 emulator_launcher.py:161] Done killing the emulator process.

s-gv avatar Sep 08 '21 10:09 s-gv

Hello @s-gv, yes, that's correct for now. Coincidentally, I am working on removing pexpect from AdbController, which should fix this bug. We just have some internal components that depend on that functionality, but I expect to work around the problems in a few weeks and then we'd be able to push a version that should work for your setup. In the meantime AndroidEnv does require a more up-to-date Python version.

kenjitoyama avatar Sep 08 '21 13:09 kenjitoyama

Thanks @kenjitoyama. Updating pexpect to 4.8.0 seems to have fixed it even in Python 3.6.

s-gv avatar Sep 08 '21 13:09 s-gv

@a-gergely, can we update pexpect in the meantime?

kenjitoyama avatar Sep 08 '21 16:09 kenjitoyama

Sorry for the delay here. For a long time now we have removed pexpect as a dependency, so this bug is not valid anymore.

kenjitoyama avatar Sep 28 '22 22:09 kenjitoyama