Skip to content

AttributeError: module 'urllib' has no attribute 'request' in a11y_grpc_wrapper.py #298

Description

@jude-sph

Description

Thanks for the work on this project.

The file android_env/wrappers/a11y_grpc_wrapper.py uses urllib.request.urlopen() but only imports urllib, not
urllib.request. This causes an AttributeError when the accessibility forwarder APK download is triggered.

Error might go unnoticed if another module imports this.

Steps to Reproduce

from android_world.env.android_world_controller import get_controller                                                
                                                                                                                     
ctrl = get_controller(                                                                                               
    console_port=5554,                                                                                               
    adb_path='~/Library/Android/sdk/platform-tools/adb',                                                             
    grpc_port=8554                                                                                                   
)                                                                                                                    
                                                                                                                     
Error                                                                                                                
                                                                                                                     
File ".../android_env/wrappers/a11y_grpc_wrapper.py", line 41, in _get_accessibility_forwarder_apk                   
    with urllib.request.urlopen(                                                                                     
         ^^^^^^^^^^^^^^                                                                                              
AttributeError: module 'urllib' has no attribute 'request'                                                           
                                                                                                                     
Environment                                                                                                          
                                                                                                                     
- android-env version: 1.2.3                                                                                         
- Python version: 3.12                                                                                               
- OS: macOS (Apple Silicon)                                                                                          
                                                                                                                     
Root Cause                                                                                                           
                                                                                                                     
Line 22 of a11y_grpc_wrapper.py:                                                                                     
import urllib                                                                                                        
                                                                                                                     
Should be:                                                                                                           
import urllib.request                                                                                                
                                                                                                                     
In Python 3, urllib is a package and submodules must be explicitly imported.                                         
                                                                                                                     
Proposed Fix                                                                                                         
                                                                                                                     
- import urllib                                                                                                      
+ import urllib.request                                                                                              
                                                                                                                     
---

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions