1

I recently installed opencv but before I run the python script i always have to run these two commands:

workon cv
source ~/.profile

I already tried running the commands at boot, here's my '/etc/rc.local':

#!/bin/sh -e

IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

/home/pi/boot.sh
# boot.sh contains those two commands
exit 0

but it didn't work.

I even tried using crontab -e, but that too didn't work

Is there any other way by which i can avoid typing those commands in future?

2

Have you made sure you're file is executable?

Try changing /home/pi/boot.sh to say this:

#!/bin/bash
workon cv
source /home/pi/profile

Then make the file executable with the following command:

chmod +x /home/pi/boot.sh

Also, rc.local is run as root so ~/profile would mean /root/profile instead of /home/pi/profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.