从终端手动运行python
脚本时,脚本会成功运行。
使用以下条目与crontab -e
一起安排时:
@reboot export DISPLAY=:0 sudo /bin/sleep 60 && gnome-terminal -e 'sudo python3 /path/to/script/script.py'
脚本失败。报告connection refused
消息。
脚本导入selenium
并依赖Firefox
webdriver在类似于kiosk的显示屏中浏览网站。
非常感谢任何帮助。
编辑:当我使用crontab
安排脚本时,终端中会打印以下错误:
Traceback (most recent call last):
File "/home/pi/Desktop/photo_frames/becky/get_urls.py", line 19, in <module>
driver = webdriver.Firefox()
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/firefox/webdriver.py", line 150, in __init__keep_alive=True)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.4/dist-
packages/selenium/webdriver/remote/errorhandler.py", line 192, in
check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused