My python script imports cv2, and it works fine when I start the script manually.
If I set the script to launch on boot (either via crontab, or via a .desktop file (in the user/.config/autostart/whatever.desktop) I get error "cv2 module not found".
I suppose the script is run in two different environments then, one that ha the cv2 module installed when I start the script manually, and in another environment that doesn't have the cv2 module installed when it is triggered automatically.
How can I rectify this?
Either have the script autorun in the same environment as when I manually trigger it, or install the applicable modules in that environment where it runs when autotriggered.
The contents of the .desktop file is
The launcher.sh script looks like this:
/usr/bin/python3 main.py > logs/bashlog.txt 2>&1
When starting from crontab (sudo crontab -e) I have this line:
@reboot sh /home/RecorderV1/Recorder/launcher.sh >/home/RecorderV1/Recorder/logs/cronlog 2>&1
I have installed cv2 with
pip install opencv-python
And like I said it works fine when I open the .py file and run it manually.