0

I try to run a python script at start of raspberry pi. In the python script I use open cv so I need to call before:

source ~/.profile
workon cv

I try to write a bash file:

#!/bin/bash

echo "Bash script"
source ~/.profile
workon cv
#/usr/bin/python3 reco_eyes_from_video.py
python reco_eyes_from_video.py

But I get this error:

Traceback (most recent call last):
File "reco_eyes_from_video.py", line 1, in <module>
import cv2
ImportError: No module named 'cv2'

If I call myself:

source ~/.profile
workon cv

and then:

python reco_eyes_from_video.py

it is working fine There is any way to run workon at the start?

qubuss
  • 268
  • 3
  • 12

1 Answers1

0

It seems that you forget to write "python" before "reco_eyes_from_video.py" in your bash file.

To run this file at start, have a look at this answer

Braba
  • 1
  • 1
  • Yeah sorry, in my script i have it. All the time i get error. That error mean i don't have cv, and this is mean workon cv doesn't work – qubuss Dec 30 '17 at 14:13
  • Did you check if you’re in the “cv” virtual environment after calling : source ~/.profile workon cv a "cv" must appear in front of the prompt of your shell. Check step 7 here: https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/ – Braba Dec 30 '17 at 15:01
  • If i call this via bash file I'm not in but if i call this one by one via terminal I am – qubuss Dec 30 '17 at 15:04
  • I'm not expert on this question, but I know my bash scripts with Python call inside may work or not if I launch them with: `bash myscript.sh` or `sh myscript.sh` or `./myscript.sh` (after making it executable via 'chmod +x myscript.sh) – Braba Dec 31 '17 at 14:27
  • Thx for help :). I reinstall python on rpi and tool python open cv and now it works. – qubuss Jan 02 '18 at 12:01