I am looking for a solution to the following bug in a Python 3.7 app engine project (Mac OS Mojave):
ValueError: unknown locale: UTF-8
I have tried all the solutions listed here (edits to my ~/.bash_profile file) without luck. 
Could it perhaps be that these proposed fixes do not work because in my case the bug occurs within an app engine environment?
Full traceback:
[2019-05-13 07:48:37,563] ERROR in app: Exception on /api/get_accounts [POST]
Traceback (most recent call last):
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/.../googleAdsApi/main.py", line 61, in get_all_accounts
    accounts = get_accounts(creds)
  File "/Users/.../googleAdsApi/services/get_accounts.py", line 7, in get_accounts
    client = get_client(creds)
  File "/Users/.../googleAdsApi/services/clients.py", line 58, in get_client
    return adwords.AdWordsClient(DEVELOPER_TOKEN, oauth2_client, USER_AGENT, cache=ZeepServiceProxy.NO_CACHE)
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/googleads/adwords.py", line 241, in __init__
    super(AdWordsClient, self).__init__()
  File "/private/var/folders/jj/9jn8lbt17kgfhr_dqdz6gd180000gn/T/tmpXEC0bT/lib/python3.7/site-packages/googleads/common.py", line 152, in __init__
    _, encoding = locale.getdefaultlocale()
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 568, in getdefaultlocale
    return _parse_localename(localename)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 495, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
INFO     2019-05-13 06:48:37,661 module.py:861] default: "POST /api/get_accounts HTTP/1.1" 500 290
What seems to be going wrong in the app engine project:
Based on the above traceback, it seems that one library I use (googleads) is trying to get my locale through locale.getdefaultlocale(), resulting in the error. 
What makes me suspect this bug is app engine specific:
When I enter the following command in my terminal (using the same python 3.7 as in the app engine environment):
python3 -c 'import locale; print(locale.getdefaultlocale());'
It returns:
('en_US', 'UTF-8')  
In other words, the very same locale.getdefaultlocale() works fine when I call it from terminal, but crashes in the app engine environment.