ImportError: No module named selenium cronjob Mac

2019-07-29 05:11发布

I am trying to automate a python script to run every minute but can't seem to figure out why I get the error:

ImportError: No module named selenium

although:

pip freeze
...
selenium==3.4.2
...

and script runs in command line.

here's what I am doing:

* * * * * cd /Users/Saleh/Desktop/MMM && python READY.py

Error:

crontab: installing new crontab You have new mail in /var/mail/Saleh Mohameds-Air:~ Saleh$ mail Mail version 8.1 6/6/93. Type ? for help. "/var/mail/Saleh": 1 message 1 new

N 1 Saleh@Mohameds-Air.l Sat May 20 13:31 22/816 "Cron cd /Users/Saleh/Desktop/MMM && python READY.py X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: Date: Sat, 20 May 2017 13:31:01 +0300 (EEST)

Traceback (most recent call last): File "READY.py", line 12, in from selenium import webdriver ImportError: No module named selenium

Path of python script is as below:

Users/Saleh/Desktop/MMM/READY.py

pls help, THANK YOU!

1条回答
一夜七次
2楼-- · 2019-07-29 05:46

You have to have the path to to your selenium driver specified when running it as a cron. for example

export PATH=path/to/your/selenium/driver/folder:$PATH && cd /Users/Saleh/Desktop/MMM && python READY.py
查看更多
登录 后发表回答