I'm trying to follow the flask tutorial in Pythonista, but I'm having a problem at the database configuration step. My problem is that it uses click commands. First off, there doesn't seem to be a way to invoke these in Pythonista. I managed to solve that problem by running the relevant function in code, however:
app = create_app()
db.init_db_command(app)
So that's fine. Unfortunately, when I run this code, I get this:
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/en/7.x/python3 for mitigation steps.
Additional information: on this system no suitable UTF-8 locales were discovered. This most likely requires resolving by reconfiguring the locale system.
Checking out that link, it seems I that I need to do:
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
Once again, I need a way to do this in code, so: (many browser tabs later...)
import os
os.environ['LC_ALL'] = 'en_US.utf-8'
os.environ['LANG'] = 'en_US.utf-8'
...and I get the same error. But it has some new stuff at the end!
Click discovered that you exported a UTF-8 locale but the locale system could not pick up from it because it does not exist. The exported locale is "en_US.utf-8" but it is not supported.
How do I know what locales are supported then?
locale -a
Sigh... yes, once again, I can't do this. so:
import locale
locale.locale_alias
which apparently does not quite map to locale -a but it's the best I can come up with. That gives me a gigantic list of stuff, which I picked through and tried every alias that looked like it might be English UTF-8. Nothing worked.
So... now I think, somehow, the needed locale is simply not installed (although that does seem odd!). However... installing a new locale seems like something Apple is not going to let me do. Which brings me to my actual question:
Can I install a locale using Pythonista? Is this possible? If so, how?
-
OR is there some other way to solve this problem?
-
OR if this is really impossible, how can I refactor the flask tutorial to not use click?