Assertion error in app.py

I’ve tried running the code a couple different ways but the end result is always this:

line 1283, in add_url_rule
"View function mapping is overwriting an "

AssertionError: View function mapping is overwriting an existing endpoint function: movies_api_v1.wrapper

earlier it was related to get_jwt_claims() method that you guys used, but I fixed that and now I’m stuck here…

Hi @decker_N_A welcome to the new forums!

Can you expand what code you are running with the full command line so I can replicate it? Can you also expand upon what fix you applied to get_jwt_claims()? Can you also share which Python library versions you have installed in your environment as well as which version of Python you are using?

The answers to these questions will better help understand where you are, what your environment is and should allow for us to better determine the problem before we can suggest the correct solution to you.

Kindest regards,
Eoin

1 Like

@Eoin_Brazil i’m working on the M220P MongoDB for Python Developers in the chapter 0 where we have to run the “python run.py” command, the command window shows this :

  File "run.py", line 11, in <module>
    app = create_app()
  File "C:\Users\ddd\desktop\.vs\try1\mflix\factory.py", line 36, in create_app
    app.register_blueprint(movies_api_v1)
  File "C:\Users\ddd\anaconda3\lib\site-packages\flask\app.py", line 98, in wrapper_func
    return f(self, *args, **kwargs)
  File "C:\Users\ddd\anaconda3\lib\site-packages\flask\app.py", line 1168, in register_blueprint
    blueprint.register(self, options, first_registration)
  File "C:\Users\ddd\anaconda3\lib\site-packages\flask\blueprints.py", line 256, in register
    deferred(state)
  File "C:\Users\ddd\anaconda3\lib\site-packages\flask\blueprints.py", line 294, in <lambda>
    self.record(lambda s: s.add_url_rule(rule, endpoint, view_func, **options))
  File "C:\Users\ddd\anaconda3\lib\site-packages\flask\blueprints.py", line 86, in add_url_rule
    **options
  File "C:\Users\ddd\anaconda3\lib\site-packages\flask\app.py", line 98, in wrapper_func
    return f(self, *args, **kwargs)
  File "C:\Users\ddd\anaconda3\lib\site-packages\flask\app.py", line 1284, in add_url_rule
    "existing endpoint function: %s" % endpoint
AssertionError: View function mapping is overwriting an existing endpoint function: movies_api_v1.wrapper

i’m running all the updated versions of the libraries mentioned in the requirments.txt

As far as get_jwt_claims() is concerned, the function was removed in the last update of the library and replaced with get_jwt().

I also have a question regarding the enviornment mflix we create, why?

As for the why? See

https://docs.python.org/3/library/venv.html

Hi @decker_N_A

To follow up on the point raised by @steevej, are you running the code in a virtual environment and if not, does running the code in a venv resolve your issue?

Kindest regards,
Eoin

no I’m afraid it does not help.

Hi @decker_N_A

In order to better understand exactly why you are encountering your assertion error with the app.py, we’ll need some further information to help frame a hypothesis. We can then test this to see if we can resolve your issue.

Can you provide the list of modules installed for your virtual environment and their versions by running the command, pip list, in your virtual environment? I’d like specifically to verify these correspond to the versions listed in the “requirements.txt” file to avoid any versioning issues with those modules where functions may have been renamed or changed.
Can you also provide the version of Python 3 you are running?

This information will help better understand your environment and what may be the factors contributing to your assertion error.

Kindest regards,
Eoin

1 Like