硒逐行工作但不在脚本中

selenium working as line-by-line but not in a script

my python script in upper left corner , error message in the middle , when i execute line by line in the lower left corner, the right half is geckodriver log

m trying to run python script using selenium module to make basic automated youtube search. I get the error show in the middle picture when I write the script as a whole but when I write the code line-by-line it works perfectly . I tried reinstalling gecko and firefox but didn不工作。 我是如何安装 gecko 的:1)un-tar file 2) make file executable 3)mv file to usr/local/bin ... 壁虎驱动程序 26.0.0 火狐 75.0 ubuntu 19.10 vim8.2

日志非常清楚错误,你不能运行 geckodriver as root,你必须运行 它在不同的用户下,你可以使用 sudo -H -u,即:

chown someuser:someuser /path/to/script.py
sudo -H -u someuser python /path/to/script.py