I have implemented a selenium script in Python to upload some pictures and content to Facebook, which I named FBUpload.py.
When I launch it this way, it works perfectly (in headless mode):
Xvfb :10 -ac &
python3 /home/someuser/scripts/FBUpload.py
Problem is, when I try to configure a cronjob that launches this same script, this way:
00 * * * * Xvfb :10 -ac &
01 * * * * python3 /home/someuser/scripts/FBUpload.py
45 * * * * kill -9 $(ps -auxw |grep Xvf|head -1| awk '{print $2}')
Then it fails with the following error:
Pyperclip could not find a copy/paste mechanism for your system
This is my setup: Ubuntu 20.04.4 LTS | Python3 | pyperclip 1.7.0
These are the Copy & paste mechanisms that I already installed:
PyQt5 5.15.6
PyQt5-Qt5 5.15.2
PyQt5-sip 12.10.1
QtPy 2.1.0
xclip 0.13-1 (in /usr/bin because it was installed via apt)
xsel 1.2.0+git9bfc13d.20180109-3 (in /usr/bin because it was installed via apt)
(I couldn't download PyQt4 or qkt as described in this post: pyperclip module raising an error message so I downloaded QtPy following the suggested solution. But the problem persists.)
I tried the fixes from posts with similar issue but none of them work for me. I am wondering if the issue has to do with users (because when I run the script with "sudo", the root user cannot find the libraries installed by the non-root user).
I also found this other question which seems to be similar (but instead of cron, the problem is systemd): Ubuntu 16.04 - Python 3 - Pyperclip in terminal and via systemd
from When running headless selenium in cron, got error "Pyperclip could not find a copy/paste mechanism for your system"
No comments:
Post a Comment