'Locale error in the Airflow while selecting a Dag

I just installed Airflow and ran an example DAG by using External Trigger(Play Button) option. When I go to DagRuns option I am getting the following exception. I used Airflow a couple of years back so I am unsure what is going wrong now. I also noticed this on top of the page

The scheduler does not appear to be running.

The DAGs list may not update, and new tasks will not be scheduled.

Though it is running.

  ((/  ( _(   )   (   _) ) (  () )  )
                    ( (  ( (_)   ((    (   )  .((_ ) .  )_
                   ( (  )    (      (  )    )   ) . ) (   )
                  (  (   (  (   ) (  _  ( _) ).  ) . ) ) ( )
                  ( (  (   ) (  )   (  ))     ) _)(   )  )  )
                 ( (  ( \ ) (    (_  ( ) ( )  )   ) )  )) ( )
                  (  (   (  (   (_ ( ) ( _    )  ) (  )  )   )
                 ( (  ( (  (  )     (_  )  ) )  _)   ) _( ( )
                  ((  (   )(    (     _    )   _) _(_ (  (_ )
                   (_((__(_(__(( ( ( |  ) ) ) )_))__))_)___)
                   ((__)        \\||lll|l||///          \_))
                            (   /(/ (  )  ) )\   )
                          (    ( ( ( | | ) ) )\   )
                           (   /(| / ( )) ) ) )) )
                         (     ( ((((_(|)_)))))     )
                          (      ||\(|(|)|/||     )
                        (        |(||(||)||||        )
                          (     //|/l|||)|\\ \     )
                        (/ / //  /|//||||\\  \ \  \ _)
-------------------------------------------------------------------------------
Node: adnans-mbp.home
-------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask_admin/base.py", line 69, in inner
    return self._run_view(f, *args, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask_admin/base.py", line 368, in _run_view
    return fn(self, *args, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask_login/utils.py", line 258, in decorated_view
    return func(*args, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/utils.py", line 380, in view_func
    return f(*args, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/utils.py", line 286, in wrapper
    return f(*args, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/utils/db.py", line 74, in wrapper
    return func(*args, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/views.py", line 1765, in graph
    show_external_logs=bool(external_logs))
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/views.py", line 389, in render
    return super(AirflowViewMixin, self).render(template, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask_admin/base.py", line 308, in render
    return render_template(template, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/templating.py", line 140, in render_template
    ctx.app,
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask/templating.py", line 120, in _render
    rv = template.render(context)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/templates/airflow/graph.html", line 22, in top-level template code
    {% import 'admin/static.html' as admin_static with context %}
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/templates/airflow/dag.html", line 21, in top-level template code
    {% import 'admin/lib.html' as lib with context %}
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/templates/airflow/master.html", line 20, in top-level template code
    {% extends "admin/master.html" %}
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/templates/admin/master.html", line 20, in top-level template code
    {% extends 'admin/base.html' %}
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask_admin/templates/bootstrap3/admin/base.html", line 38, in top-level template code
    {% block page_body %}
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/templates/admin/master.html", line 191, in block "page_body"
    {% block body %}
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/airflow/www/templates/airflow/graph.html", line 40, in block "body"
    Base date: {{ form.base_date(class_="form-control") }}
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/wtforms/fields/core.py", line 155, in __call__
    return self.meta.render_field(self, kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/wtforms/meta.py", line 56, in render_field
    return field.widget(field, **render_kw)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/flask_admin/form/widgets.py", line 63, in __call__
    return super(DateTimePickerWidget, self).__call__(field, **kwargs)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/wtforms/widgets/core.py", line 181, in __call__
    kwargs['value'] = field._value()
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/wtforms/fields/core.py", line 736, in _value
    return self.data and self.data.strftime(self.format) or ''
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/pendulum/mixins/default.py", line 124, in strftime
    return self.format(fmt, _locale.getlocale()[0], 'classic')
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/locale.py", line 587, in getlocale
    return _parse_localename(localename)
  File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/locale.py", line 495, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8


Solution 1:[1]

I spent several days with the issue

ValueError: unknown locale: UTF-8

If you've already tried everything, check if your IDE is up to date. In my case, I just updated PyCharm from 2020 to 2021 and the problem disappeared.

Wish you all the best!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sergei