简体   繁体   中英

Raspberry pi call workon cv in bash or python script

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM