2

I have written a python script that runs successfully on raspberry pi if it is run manually from the console. As I want to start the script on reboot, I've written a bash script to change directory, set up the environment and run the python script. Upon checking the log, however, I have noticed that an error occurs when trying to import a library. Upon executing the following line:

from openvino.inference_engine import IENetwork, IEPlugin

an error is thrown:

Traceback (most recent call last):

File "realtime_objectdetection_and_tracking_async.py", line 23, in <module>
    from custom_module... ImportError: No module named 'openvino.inference_engine'

If I run the same line from the console, there is no error:

pi@raspberrypi:~/workspace/counting-cars-with-backend-conn $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)  [GCC 6.3.0 20170516] on
linux Type "help", "copyright", "credits" or "license" for more information.
>>> from openvino.inference_engine import IENetwork, IEPlugin

Therefore, as OpenVINO installation added to .bashrc the following line:

# OpenVINO
source ~/inference_engine_vpu_arm/bin/setupvars.sh

I tried to do the same in the startup script before running the python script:

#!/bin/bash
source /home/pi/inference_engine_vpu_arm/bin/setupvars.sh 
cd /home/pi/workspace/counting-cars-with-backend-conn 
python3 realtime_objectdetection_and_tracking_async.py &

Then I added the script to cron table by running crontab -e:

@reboot sh /home/pi/run_object_detection_and_tracking.sh

As this doesn't fix the issue (ImportError above), I don't know what should be additionally configured/modified in order to get the same behaviour as in the case of running the python script from the console.

2
  • What operating system are you using? Does your sh shell have a source command? Does it work if you use . /home/pi/inference_engine_vpu_arm/bin/setupvars.sh instead of source ...?
    – terdon
    Commented Jan 30, 2019 at 12:28
  • I believe the reason for this is dew to the fact that when booting up vs being booted and at the console, the things/resources available are not the same. Like while booting: X is not available, so things that require X are not nor should not be ran yet. vino is a desktop sharing app and requires X. Commented Jan 30, 2019 at 13:08

1 Answer 1

0

I would suggest putting your script in /etc/init.d and putting a symlink to it in /etc/rc5.d and make sure the script is chmod +x. This should run your script at a time that has the same things available as at the terminal when already booted. Thus it should no longer throw errors.

Reference: Run Levels on Linux

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .