I added flask==2.1.3 to my requirements and it worked.

The important thing is to have a matching version of Werkzeug and Flask.

This issue seems to occur if you have Flask >= 2.2.x but with Werkzeug < 2.2.x

Answer from Mark on Stack Overflow
🌐
Reddit
reddit.com › r/flask › sudden error message - please help
r/flask on Reddit: Sudden Error Message - Please help
August 10, 2022 -

Hello,

Recently I started to work with Flask and have had no problems until today. I tried to run my program through Pycharm and now I keep getting the following error message:

Traceback (most recent call last):
  File "C:\Users\81704\PycharmProjects\flask-secrets\main.py", line 1, in <module>
    from flask import Flask, render_template
  File "C:\Users\81704\PycharmProjects\password-manager-start\venv\lib\site-packages\flask\__init__.py", line 4, in <module>
    from . import json as json
  File "C:\Users\81704\PycharmProjects\password-manager-start\venv\lib\site-packages\flask\json\__init__.py", line 8, in <module>
    from ..globals import current_app
  File "C:\Users\81704\PycharmProjects\password-manager-start\venv\lib\site-packages\flask\globals.py", line 56, in <module>
    app_ctx: "AppContext" = LocalProxy(  # type: ignore[assignment]
TypeError: LocalProxy.__init__() got an unexpected keyword argument 'unbound_message'

This error message has only started to appear a few hours ago. I also get the same error message on previous work when I try to run the programs. So far I have been unable to figure out what the cause of this error message is or how I can go about dealing with the problem. Any help and advice would be much appreciated. Thank you.

Discussions

bug: Flask 2.2.0 released, broken. Localstack should pin to earlier versions.
Is there an existing issue for this? I have searched the existing issues Current Behavior Starting localstack start --host fails due to: ... from flask_cors import CORS File "/mnt/d/PyProjects... More on github.com
🌐 github.com
2
August 4, 2022
[BUG] LocalProxy.__init__() got an unexpected keyword argument
When I try to run Anki (from the terminal) I get the following error: Running with temporary Qt5 compatibility shims. Run with DISABLE_QT5_COMPAT=1 to confirm compatibility with Qt6. Traceback (most recent call last): File "/usr/bin/anki", line 17, in import aqt File "/usr/lib/python3.10/s... More on forums.ankiweb.net
🌐 forums.ankiweb.net
0
0
October 24, 2022
Problem running 0.6.20 due to flask and werkzeug conflicts
Describe the bug/problem I attempted a clean install of calibre-web using pip into a new virtualenv to upgrade to 0.6.20. I received the following error when I run CPS: TypeError: __init__() got an unexpected keyword argument 'unbound_me... More on github.com
🌐 github.com
7
March 28, 2023
TypeError: __init__() got an unexpected keyword argument 'unbound_message'
Hi, I have followed the steps given in the chapter to set up mflix app. After completing all the procedure, the following error was thrown while running run.py TypeError: init() got an unexpected keyword argument ‘unbound_message’ Please help me to resolve it. More on mongodb.com
🌐 mongodb.com
1
1
August 6, 2022
🌐
GitHub
github.com › localstack › localstack › issues › 6587
bug: Flask 2.2.0 released, broken. Localstack should pin to earlier versions. · Issue #6587 · localstack/localstack
August 4, 2022 - ... from flask_cors import CORS File "/mnt/d/PyProjects/proj/venv3.9/lib/python3.9/site-packages/flask_cors/__init__.py", line 11, in <module> from .decorator import cross_origin File "/mnt/d/PyProjects/proj/venv3.9/lib/python3.9/site-packages/flask_cors/decorator.py", line 13, in <module> from flask import make_response, request, current_app File "/mnt/d/PyProjects/proj/venv3.9/lib/python3.9/site-packages/flask/__init__.py", line 4, in <module> from . import json as json File "/mnt/d/PyProjects/proj/venv3.9/lib/python3.9/site-packages/flask/json/__init__.py", line 8, in <module> from ..globals import current_app File "/mnt/d/PyProjects/proj/venv3.9/lib/python3.9/site-packages/flask/globals.py", line 56, in <module> app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment] TypeError: __init__() got an unexpected keyword argument 'unbound_message'
Author   localstack
🌐
Lightrun
lightrun.com › answers › plotly-dash-bug-flask-220-unbound_message-error
[BUG] Flask 2.2.0 unbound_message error.
“Traceback (most recent call last): File "/workspace/app.py", line 2, in <module> import dash File "/app/.heroku/python/lib/python3.9/site-packages/dash/__init__.py", line 5, in <module> from .dash import Dash, no_update # noqa: F401,E402 File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 17, in <module> import flask File "/app/.heroku/python/lib/python3.9/site-packages/flask/__init__.py", line 4, in <module> from . import json as json File "/app/.heroku/python/lib/python3.9/site-packages/flask/json/__init__.py", line 8, in <module> from ..globals import current_app File "/app/.heroku/python/lib/python3.9/site-packages/flask/globals.py", line 56, in <module> app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment] TypeError: __init__() got an unexpected keyword argument 'unbound_message'”
🌐
Anki
forums.ankiweb.net › help
[BUG] LocalProxy.__init__() got an unexpected keyword argument - Help - Anki Forums
October 24, 2022 - When I try to run Anki (from the terminal) I get the following error: Running with temporary Qt5 compatibility shims. Run with DISABLE_QT5_COMPAT=1 to confirm compatibility with Qt6. Traceback (most recent call last): …
🌐
GitHub
github.com › malwaredllc › byob › issues › 607
TypeError: __init__() got an unexpected keyword argument 'unbound_message' · Issue #607 · malwaredllc/byob
Traceback (most recent call last): File "run.py", line 1, in from buildyourownbotnet import create_app File "/root/byob/web-gui/buildyourownbotnet/init.py", line 2, in from flask import Flask File "/usr/local/lib/python3.8/dist-packages/flask/init.py", line 4, in from . import json as json File "/usr/local/lib/python3.8/dist-packages/flask/json/init.py", line 8, in from ..globals import current_app File "/usr/local/lib/python3.8/dist-packages/flask/globals.py", line 56, in app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment] TypeError: init() got an unexpected keyword argument 'unbound_message'
Author   malwaredllc
Find elsewhere
🌐
GitHub
github.com › janeczku › calibre-web › issues › 2730
Problem running 0.6.20 due to flask and werkzeug conflicts · Issue #2730 · janeczku/calibre-web
March 28, 2023 - It appears this is a problem with the version combination of flask and werkzeug: https://bobbyhadz.com/blog/python-typeerror-init-got-an-unexpected-keyword-argument-unbound-message
Author   janeczku
🌐
The Mail Archive
mail-archive.com › notifications@superset.apache.org › msg147544.html
[GitHub] [superset] srinisubramanian opened a new issue, #20942: Superset Fresh Install or Upgrade results in TypeError
August 2, 2022 - Both result in the same issue : ...ges/flask/globals.py", line 56, in <module> app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment] TypeError: __init__() got an unexpected keyword argument 'unbound_message' ``` ### Expected results Superset should run normally ### Actual ...
🌐
Intlfriendship
rixb.intlfriendship.org › localproxyinit()-got-an-unexpected-keyword-argument-unbound-message › 52395570
Localproxy.__init__() got an unexpected keyword argument ...
fbhxv kjacui hvc [BUG] LocalProxy.__init__() got an unexpected keyword … Web13 May 2019 · The initializer for the RandomForestRegressor class has no declared keyword arguments, it takes none at all. You'll either need to explicitly add them in or add kwargs to the signature. class RandomForestRegressor (RandomForest): def __init__ (self, **kwargs): … zawe Fix CI error __init__() got an unexpected keyword … TypeError: __init__ () got an unexpected keyword …
🌐
Postgres Professional
postgrespro.com › list › thread-id › 2635936
Thread: PGadmi4 - Unable to set up dev environment : Postgres Professional
Traceback (most recent call last): ...ges/flask/globals.py", line 56, in <module> app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment] TypeError: __init__() got an unexpected keyword argument 'unbound_message'...
🌐
GitHub
github.com › plotly › dash › issues › 2184
[BUG] Flask 2.2.0 unbound_message error. · Issue #2184 · plotly/dash
import json as json File "/usr/local/lib/python3.8/dist-packages/flask/json/init.py", line 8, in from ..globals import current_app File "/usr/local/lib/python3.8/dist-packages/flask/globals.py", line 56, in app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment] TypeError: init() got an unexpected keyword argument 'unbound_message' [2022-08-08 11:24:34 +0200] [9] [INFO] Worker exiting (pid: 9) [2022-08-08 11:24:34 +0200] [10] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker
Author   plotly
🌐
GitHub
github.com › wikispeedruns › wikipedia-speedruns › issues › 459
Flask runtime TypeError: __init__() got an unexpected keyword argument 'unbound_message' · Issue #459 · wikispeedruns/wikipedia-speedruns
November 14, 2022 - Ran into this issue after reinstalling everything. requirements.txt upgraded Flask. Seems like this issue is related to the most recent version of Flask (2.2.2): apache/superset#20942 Downgrading to 2.1.3 solved the issue for me, as the ...
Author   wikispeedruns
🌐
University of Washington
delphinqa.ling.washington.edu › ltdb
LTDB requirements and virtualenv - LTDB - DELPH-IN Discourse
November 10, 2023 - This is probably a bash/virtualenv question, not really an LTDB question, my apologies… I am a bit confused about how I am supposed to set up and use virtual environments for LTDB. It comes with a requirements.txt, and…
🌐
GitHub
github.com › apache › superset › issues › 20942
Superset Fresh Install or Upgrade results in TypeError · Issue #20942 · apache/superset
August 2, 2022 - I have tried both upgrading from Superset 1.5 and installing Superset 2.0 in a separate pyenv. Both result in the same issue : TypeError: init() got an unexpected keyword argument 'unbound_message' How to reproduce the bug I followed the...
Author   apache
🌐
Stack Overflow
stackoverflow.com › questions › tagged › flask-restx
Highest scored 'flask-restx' questions - Stack Overflow
April 11, 2022 - Stack Overflow | The World’s Largest Online Community for Developers
🌐
GitHub
github.com › malwaredllc › byob › issues › 651
Issue AttributeError: module 'sqlalchemy.orm' has no attribute 'DeclarativeMeta' · Issue #651 · malwaredllc/byob
March 5, 2023 - Traceback (most recent call last): File "run.py", line 1, in from buildyourownbotnet import create_app File "/root/byob/web-gui/buildyourownbotnet/init.py", line 2, in from flask import Flask File "/usr/local/lib/python3.8/dist-packages/flask/init.py", line 4, in from . import json as json File "/usr/local/lib/python3.8/dist-packages/flask/json/init.py", line 8, in from ..globals import current_app File "/usr/local/lib/python3.8/dist-packages/flask/globals.py", line 56, in app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment] TypeError: init() got an unexpected keyword argument 'unbound_message'
Author   malwaredllc
🌐
Reddit
reddit.com › r/learnpython › unexpected keyword argument error in syncpostgrestclient.__init__()
r/learnpython on Reddit: Unexpected Keyword Argument error in SyncPostgrestClient.__init__()
July 10, 2024 -

Hi y'all,

I'm not sure if this is the right place for this question, but none of the other python subs looked like the place to ask.

I have been working with Supabase lately. I haven't used the controller I made for it in a couple weeks, but it was working fine then. I went to do something on it tonight and I'm getting this weird error:

ERROR:controllers.supabase_controller:Error inserting data into salesforce_opportunities_lake: SyncPostgrestClient.__init__() got an unexpected keyword argument 'verify'

Somehow a 'verify' argument is being passed to this class. I'm not passing it in, just the url and the key just like Supabase says to. I confirmed I have the updated Supabase package installed in my environment.

I tried to look around in stackoverflow and even used chatGPT but I couldn't find any solutions. chatGPT suggested to check the documentation for any changes but I can't find anything about a ghost inserting a keyword argument that isn't there (see code below). However, I'll be the first to admit that I am not good at comprehending documentation.

Here's the relevant portion of the Supabase controller I wrote:

import os
import logging
from supabase import create_client
from dotenv import load_dotenv

load_dotenv()

class SupabaseController:
    def __init__(self):
        self.url = os.environ.get('SUPABASE_URL')
        self.key = os.environ.get('SUPABASE_KEY')
        self.client = self._create_client()

        logging.basicConfig(level=logging.INFO)
        self.logger = logging.getLogger(__name__)

    def _create_client(self):
        '''
        Checks for the existence of environment variables and creates a Supabase client if they are set
        '''
        if not self.url or not self.key:
            raise ValueError('Supabase API key and URL must be set in environment variables')
        return create_client(self.url, self.key)
    
    def select_data_from_table(self, table_name):
        '''
        Selects data from the given table
        '''
        limit = 1000
        offset = 0
        all_data = []

        while True:
            try:
                data = self.client.table(table_name).select('*').range(offset, offset + limit -1).execute()

                if len(data.data) == 0:
                    self.logger.info(f"All data retrieved from {table_name}.")
                    break

                all_data.extend(data.data)
                offset += limit

                self.logger.info(f"Retrieved {len(all_data)} records from {table_name}.")
            except Exception as e:
                self.logger.error(f"Error retrieving data from {table_name}: {e}")
                break

        return all_data
    
    def insert_data_to_table(self, table_name, data):
        '''
        Inserts data to the given table
        '''
        try:
            response = self.client.table(table_name).insert(data).execute()
            if len(response.data) == 0:
                self.logger.warning(f"No data inserted to {table_name}.")
            else:
                self.logger.info(f"Data inserted into {table_name}.")
        except Exception as e:
            self.logger.error(f"Error inserting data into {table_name}: {e}")

I've double and triple checked the environment variables and they are correct.

And just to clarify - the _create_client() is operating, not throwing a valueerror. I'm getting the keyword errors on every item I try to insert into the table, also getting the error when I'm trying to select data from the table.

And here's the implementation:

from datetime import datetime
import pytz
from tqdm import tqdm

from controllers.salesforce_controller import SalesforceController
from controllers.supabase_controller import SupabaseController
from pipelines import query_strings

class SalesforcePipeline:
    def __init__(self):
        self.salesforce_controller = SalesforceController()
        self.supabase_controller = SupabaseController()

        self.table_name = 'salesforce_opportunities_lake'
        self.opportunities_query_string = query_strings.SALESFORCE_OPPORTUNITIES

    def opportunities_job(self):
        existing_opportuties = self.supabase_controller.select_data_from_table(table_name=self.table_name)
        opportunities_data = self.salesforce_controller.fetch_salesforce_data(self.opportunities_query_string)
        opportunities = self.parse_opportunities(opportunities_data)
        self.update_opportunities(existing_opportuties, opportunities)

# A bunch of code here not relevant to this question
    
    def update_opportunities(self, existing_opportuties, opportunities):
        '''
        Updates opportunities data in Supabase table
        '''
        existing_ids = [opportunity['opportunity_id'] for opportunity in existing_opportuties]

        for opportunity in tqdm(opportunities):
            if opportunity['opportunity_id'] in existing_ids:
                self.supabase_controller.update_data_in_table(table_name=self.table_name, data=opportunity, id=opportunity['opportunity_id'])
            else:
                self.supabase_controller.insert_data_to_table(table_name=self.table_name, data=opportunity)

main.py:

from pipelines.salesforce_pipeline import SalesforcePipeline

def update_lake():
    salesforce = SalesforcePipeline()
    salesforce.opportunities_job()

if __name__ == '__main__':
    update_lake()