I am using raspberrypi4 trying to run fswebcam from within a virtual env , but i get error when i do so
(rasberry-pi-env) rishil@raspberrypi:~/proj $ ./obj-detector.py
Traceback (most recent call last):
File "/home/rishil/proj/./obj-detector.py", line 27, in <module>
fswebcam -r1280x720 --no-banner /home/rishil/proj/sample1.jpg
^^^^^^^^
NameError: name 'fswebcam' is not defined
when i call fswebcam from within virtual env it works fine
(rasberry-pi-env) rishil@raspberrypi:~/proj $ fswebcam -r 1280x720 --no-banner ./s1.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Disabling banner.
Writing JPEG image to './s1.jpg'.
when i apt list from within virtual env it works fine
(rasberry-pi-env) rishil@raspberrypi:~/proj $ apt list --installed | grep fsw
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
fswebcam/stable,now 20140113-2 armhf [installed]
code inside my python script is
#!/usr/bin/env python
import boto3
import io
access_key_id = 'xx'
secret_access_key = 'yy'
client = boto3.client('rekognition', region_name='us-west-2',
aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)
fswebcam -r1280x720 --no-banner /home/rishil/proj/sample1.jpg
photo = '/home/rishil/proj/sample1.jpg'
with open(photo, 'rb') as image_file:
source_bytes = image_file.read()
detect_objects = client.detect_labels(Image={'Bytes': source_bytes})
print(detect_objects)
image = Image.open(io.BytesIO(source_bytes))
draw = ImageDraw.Draw(image)
for label in detect_objects['Labels']:
print(label["Name"])
print("Confidence: ", label["Confidence"])
not sure what i could be doing wrong , any idea? I am suspecting it could be related to first line where i am instantiating global python env again ... i tried changing it to
'#!source rasberry-pi-env/bin/activate'
then came out of virtual env and ran script , got a strange error
rishil@raspberrypi:~/proj $ ls
obj-detector-backup.py obj-detector.py rasberry-pi-env s1.jpg sample.jpg
rishil@raspberrypi:~/proj $ ./obj-detector.py
bash: ./obj-detector.py: cannot execute: required file not found
rishil@raspberrypi:~/proj $ python ./obj-detector.py
Traceback (most recent call last):
File "/home/rishil/proj/./obj-detector.py", line 4, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3'
What am i doing wrong ?