SyntaxError: invalid syntax on mflix-python/mflix/db.py line 274

Hallo, after following the instructions and reading the discussions I still get the following error:

File “/Users/Administrator/M220/mflix-python/mflix/api/movies.py”, line 2, in
from mflix.db import get_movie, get_movies, get_movies_by_country,
File “/Users/Administrator/M220/mflix-python/mflix/db.py”, line 274
except (StopIteration) as _:
^
SyntaxError: invalid syntax

I have installed anaconda3 and the requirements.txt

[PROD]
SECRET_KEY = super_secret_key_you_should_change
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-p2un5.mongodb.net/mflix

I would appreciate your help to get in running.
Best regards Tilo

Thanks, shifting the “except” to the try level to the left helped and it is working now. Regards Tilo

5 Likes

Tilo, i look that you dont have set a secret key:
SECRET_KEY = super_secret_key_you_should_change
here you can create one
https://docs.atlas.mongodb.com/configure-api-access/

1 Like

I am getting the same “invalid syntax” error. I have created a secret key and have run pip for requirements.txt. As a clarification, does the secret key just go under the [PROP] section of the .ini file? Show I use the same key under [TEST] or create a new key? Any other ideas why the syntax error might occur?

Thanks
Frank

Tonight I saw one of the comments concerning the incorrect tabbing in the db.py file. I downloaded the new version of the project and was able to continue without error.

1 Like

Hi! Where I find this version?