2

I am having some issues using the cloudvisreq python script for the Google Vision Python API. I get this error when I run the code:

File "newvisreq.py", line 46
    api_key, *image_filenames = argv[1:]
             ^
SyntaxError: invalid syntax

I am running the script through Python2.7, as it told me to in the tutorial I'm using to set this up. I found when I ran it through Python3 it was slightly more successful, as it managed to write as it was supposed to, but it received no data. The code can be found here, and the line the error complains about is about half way through the file (line 46).

Thanks in advance,

Connor

1
  • This is a feature of python-3. Commented Jul 7, 2017 at 8:58

1 Answer 1

2

This advanced form of iterable unpacking (PEP-3132), is only available from (and further versions). You can however use the following code to make it equivalent:

api_key = argv[1]
image_filenames = argv[2:]

In case argv is not a list (if it is imported from sys, it is a list), you can use:

api_key = argv[1]
image_filenames = list(argv[2:])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.