PHP前端开发

DrissionPage 启动报错:参数错误,如何解决?

百变鹏仔 5天前 #Python
文章标签 报错

drissionpage:一启动就报错?如何解决

使用 drissionpage 时,可能会遇到启动时报错的问题,如下所示:

traceback (most recent call last):  file "test1.py", line 7, in <module>    page = chromiumpage()  file "d:hostipalmyvenvlibsite-packagesdrissionpagechromium_page.py", line 33, in __init__    super().__init__(addr_driver_opts, tab_id, timeout)  file "d:hostipalmyvenvlibsite-packagesdrissionpagechromium_base.py", line 36, in __init__    self._connect_browser(address, tab_id)  file "d:hostipalmyvenvlibsite-packagesdrissionpagechromium_page.py", line 46, in _connect_browser       self.process = connect_browser(self._driver_options)[1]  file "d:hostipalmyvenvlibsite-packagesdrissionpageunctionsrowser.py", line 41, in connect_browser    debugger = _run_browser(port, chrome_path, args)  file "d:hostipalmyvenvlibsite-packagesdrissionpageunctionsrowser.py", line 131, in _run_browser      debugger = popen(arguments, shell=false)  file "c:users8467ppdatalocalprogramspythonpython38libsubprocess.py", line 854, in __init__         self._execute_child(args, executable, preexec_fn, close_fds,  file "c:users8467ppdatalocalprogramspythonpython38libsubprocess.py", line 1307, in _execute_child    hp, ht, pid, tid = _winapi.createprocess(executable, args,oserror: [winerror 87] 参数错误。

这种错误通常是由于以下原因引起的:

解决方案:

1. 指定 chrome 路径

如果 drissionpage 找不到 chrome,请指定 chrome 可执行文件的路径:

from drissionpage import chromiumpage, chromiumoptionsco = chromiumoptions().set_paths(browser_path=r'你电脑chrome.exe路径')page = chromiumpage(addr_driver_opts=co)

2. 升级 chrome

如果 chrome 版本太低,请升级到最新版本:

pip install DrissionPage --upgrade

升级后,重新启动 python 脚本,问题应该得到解决。

其他建议: