I have written the following script which is supposed to change directory on startup and then run the script as pi user (on raspberry pi):
#!/bin/bash echo 'raspberry' | sudo su - pi -c 'cd /home/pi/workspace/counting-objects && python3 script.py
If I run the script, I get the following error:
Traceback (most recent call last): File "script.py", line 23, in <module> from custom_module... ImportError: No module named 'custom_module'
If I manually change the folder on login and then run the same script from console, everything works as expected.
Does anyone know how to fix the bash script in order to run correctly the script as pi user after changing directory?