我目前正在使用 Chaquopy 将 Python 代码实现到 Android Studio 中。但是,我无法在 Python 中初始化 selenium 的 chromedriver。每当我尝试使用该行进行初始化时driver = webdriver.Chrome("/path/to/chromedriver.exe, options=opt)
,我都会收到错误消息“WebDriverException:消息:'chromedriver.exe' 可执行文件可能具有错误的权限”或“WebDriverException:消息:'chromedriver' 可执行文件需要在 PATH 中”。因此,我导入了 ChromeDriverManager 并调用了driver = webdriver.Chrome(ChromeDriverManager().install(), options=opt)
. 运行我的程序会出现以下错误:
Process: com.example.test3, PID: 20964
com.chaquo.python.PyException: ValueError: Could not get version for Chrome with this command: google-chrome --version
at <python>.webdriver_manager.utils.chrome_version(utils.py:112)
at <python>.webdriver_manager.driver.get_latest_release_version(driver.py:58)
at <python>.webdriver_manager.manager.__get_latest_driver_version(manager.py:21)
at <python>.webdriver_manager.manager.__get_version_to_download(manager.py:27)
at <python>.webdriver_manager.manager.download_driver(manager.py:36)
at <python>.webdriver_manager.chrome.install(chrome.py:28)
at <python>.login.web_scrape(login.py:57)
at <python>.chaquopy_java.call(chaquopy_java.pyx:281)
at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrows(chaquopy_java.pyx:253)
at com.chaquo.python.PyObject.callAttrThrows(Native Method)
at com.chaquo.python.PyObject.callAttr(PyObject.java:209)
at com.example.test3.LoginWaterloo$1.onClick(LoginWaterloo.java:37)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
有关如何克服此错误的任何建议?我看到一个帖子有同样的问题,但无法理解答案。