I am having an issue with the following section of Python code:
import sys
import requests
import firebase_admin
from firebase_admin import credentials
f
sys.argv
list is populated from the command line arguments passed to the script, so in case none are provided it's expected to get an error like
Traceback (most recent call last):
File "demo4.py", line 6, in
image_url = sys.argv[1]
IndexError: list index out of range
An easy repro is to put
import sys
print(sys.argv[1])
in demo.py
and run it using python demo.py
. You'll get the output
$ python demo.py
Traceback (most recent call last):
File "demo.py", line 2, in
print(sys.argv[1])
IndexError: list index out of range
but if you pass an argument to it using python demo.py foo
you'll get the desired output:
$ python demo.py foo
foo
Specifically for your example, looks like when calling demo4.py
script you're not passing image url command line argument. You can pass it using python demo4.py
.