You are not logged in.

#1 2017-11-25 14:25:23

osintusr
Member
Registered: 2017-11-03
Posts: 18

[SOLVED] Anki exception: 'requires UTF-8 locale'

Dear all,

I have just installed Anki from the official repos onto a recently installed Arch system (no prior install of Anki). I get this error when I try to run the program from the command line:

Traceback (most recent call last):
  File "/usr/bin/anki", line 6, in <module>
    import aqt
  File "/usr/share/anki/aqt/__init__.py", line 4, in <module>
    from anki import version as _version
  File "/usr/share/anki/anki/__init__.py", line 11, in <module>
    raise Exception("Anki requires a UTF-8 locale.")
Exception: Anki requires a UTF-8 locale.

I have tried some of the suggestions offered in this thread (of course, the issue is slightly different, but I tried to troubleshoot using roughly the same methods.)

Here is some output that may be useful:

uname -a
Linux thinkpad 4.9.62-1-lts #1 SMP Wed Nov 15 17:49:37 CET 2017 x86_64 GNU/Linux
localectl
       System Locale: LANG=sv_SE.UTF-8
       VC Keymap: se-lat6
       X11 Layout: n/a
locale -a
C
POSIX
sv_SE.utf8
python2 -c "import sys; print sys.getfilesystemencoding()"
ANSI_X3.4-1968
grep -v '#' /etc/locale.gen
sv_SE.UTF-8 UTF-8
env | grep LANG
LANG=C

I'm not sure why python2 is encoded thus, or how I can change it, if that's the problem. I had a read through PEP 540 but still unsure what next steps to take.

SOLUTION: Install relevant Python modules for my Python distribution (Anaconda).

Last edited by osintusr (2017-11-25 15:06:24)

Offline

#2 2017-11-25 14:41:37

osintusr
Member
Registered: 2017-11-03
Posts: 18

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

UPDATE

I ran the following command:

export LC_CTYPE=sv_SE.UTF-8

which seems to have fixed the UTF-8 error. However, when I run

anki

now I get the following error:

Traceback (most recent call last):
  File "/usr/bin/anki", line 6, in <module>
    import aqt
  File "/usr/share/anki/aqt/__init__.py", line 4, in <module>
    from anki import version as _version
  File "/usr/share/anki/anki/__init__.py", line 14, in <module>
    from anki.storage import Collection
  File "/usr/share/anki/anki/storage.py", line 11, in <module>
    from anki.collection import _Collection
  File "/usr/share/anki/anki/collection.py", line 26, in <module>
    from anki.sound import stripSounds
  File "/usr/share/anki/anki/sound.py", line 258, in <module>
    import pyaudio
ModuleNotFoundError: No module named 'pyaudio'

Is this an "upstream" problem?

Offline

#3 2017-11-25 14:44:16

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,019

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

The anki package requires the python-pyaudio package. You should have it, unless you've done something dumb like changing the "python" symlink.

Offline

#4 2017-11-25 14:46:47

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

python2 ...

stat /usr/lib/python3.6/site-packages/pyaudio.py

Offline

#5 2017-11-25 14:48:40

osintusr
Member
Registered: 2017-11-03
Posts: 18

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

Hmm I'm confused now.
I installed python-pyaudio and python2-pyaudio but get the same error and

which python-pyaudio

shows it is not in the path.
I definitely haven't messed with any symlinks.
I had a similar issue with other programs because I had not installed the package corresponding to the lts kernel.

Offline

#6 2017-11-25 14:50:07

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,019

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

I have no idea what you expect to be in $PATH for a python library.

Offline

#7 2017-11-25 14:50:59

osintusr
Member
Registered: 2017-11-03
Posts: 18

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

Fair point.

Offline

#8 2017-11-25 14:52:49

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

python --version
pacman -Qkk python-pyaudio

?

Last edited by seth (2017-11-25 14:53:16)

Offline

#9 2017-11-25 14:54:47

osintusr
Member
Registered: 2017-11-03
Posts: 18

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

Ah could it be that I'm using

Python 3.6.3 :: Anaconda, Inc.

?

pacman -Qkk python-pyaudio
python-pyaudio: 14 total files, 0 altered files

Offline

#10 2017-11-25 14:56:52

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] Anki exception: 'requires UTF-8 locale'

osintusr wrote:

Ah could it be that I'm using

Python 3.6.3 :: Anaconda, Inc.

?

Yes.

Offline

Board footer

Powered by FluxBB