There is a python file
#!/usr/bin/ python from pyvirtualdisplay import Display from selenium import webdriver def main(): with Display(visible=False, size=(1200, 1500)): firefox_dir = "/usr/bin/selenium/webdriver/firefox" ff_profile = webdriver.FirefoxProfile(profile_directory=firefox_dir) browser = webdriver.Firefox(ff_profile) browser.get("http://www.python.org") print browser.title browser.close() if __name__ == "__main__":main() There is a task in crown * * * * * export DISPLAY =: 0 && / usr / bin / python /var/www/test/test.py> /tmp/listener_new.log 2> & 1
Beats mistake
Traceback (most recent call last): File "/var/www/test/test.py", line 14, in <module> if __name__ == "__main__":main() File "/var/www/test/test.py", line 9, in main browser = webdriver.Firefox(ff_profile) File "/home/dev/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__ self.service.start() File "/home/dev/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 83, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. Tell me, good people, what could be the error? From the terminal, the script starts and runs.
shutil.which('geckodriver')) Is it inos.environ['PATH']? (when starting from cron) - jfsprint(os.environ['PATH'])add to your script when it starts from cron (if you don’t know what $ PATH is the environment variable, ask a separate question). Compare with thepython -с "import shutil; print(shutil.which('geckodriver'))"directory shown by the command in the terminal. - jfs