You are not logged in.

#1 2015-06-03 06:28:47

charli3
Member
Registered: 2015-06-01
Posts: 45

[SOLVED] error when tried to run Anki "requires a UTF-8 locale"

Traceback (most recent call last):
  File "/usr/bin/anki", line 5, in <module>
    import aqt
  File "/usr/share/anki/aqt/__init__.py", line 12, in <module>
    from aqt.qt import *
  File "/usr/share/anki/aqt/qt.py", line 10, in <module>
    from anki.utils import isWin, isMac
  File "/usr/share/anki/anki/__init__.py", line 14, in <module>
    raise Exception("Anki requires a UTF-8 locale.")
Exception: Anki requires a UTF-8 locale.

Not sure what this means or how to trouble shoot, any help would be appreciated.  Still a little bit of a noob.  Thanks!

Last edited by charli3 (2015-06-10 01:01:13)

Offline

#2 2015-06-03 06:31:40

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-06-03 08:13:42

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

When posting configs, code or command output, please use [ code ] tags, not [ quote ] tags https://bbs.archlinux.org/help.php#bbcode

like this

It makes the code more readable and - in case of longer listings - more convenient to scroll through.

Post the output of

uname -a
localectl
locale -a

Offline

#4 2015-06-03 17:55:21

charli3
Member
Registered: 2015-06-01
Posts: 45

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

Will do!

Offline

#5 2015-06-08 13:30:46

charli3
Member
Registered: 2015-06-01
Posts: 45

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

Sorry it took me a while to get back to this but here's the output you asked for.

uname -a
Linux charli3-cpu 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:05:23 UTC 2015 x86_64 GNU/Linux
localectl                            
   System Locale: LANG=en_US.UTF-8
       VC Keymap: n/a
      X11 Layout: n/a
locale -a
C
POSIX
en_US.utf8

Offline

#6 2015-06-08 15:08:43

mauritiusdadd
Member
From: Benevento, Italy
Registered: 2013-10-27
Posts: 776

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

Why POSIX has precedence over en_US.utf8? Can you also post the output of the following commands?

python2 -c "import sys; print sys.getfilesystemencoding()"
grep -v '#' /etc/locale.gen
env | grep LANG

Last edited by mauritiusdadd (2015-06-08 15:12:15)


About me - github

-- When you have eliminated the impossible, whatever remains, however improbable, must be the truth -- Spock | Sherlock Holmes

Offline

#7 2015-06-09 13:21:24

charli3
Member
Registered: 2015-06-01
Posts: 45

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

No problem.

$ python2 -c "import sys; print sys.getfilesystemencoding()"
UTF-8
$ grep -v '#' /etc/locale.gen
en_US.UTF-8 UTF-8
$ env | grep LANG
LANG=en_US.UTF-8

(Is that Spock piped through Sherlock with Holmes args?)

Last edited by charli3 (2015-06-09 13:27:42)

Offline

#8 2015-06-09 13:53:39

mauritiusdadd
Member
From: Benevento, Italy
Registered: 2013-10-27
Posts: 776

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

Ok, this is wierd...

From the traceback you posted an exception is raised in /usr/share/anki/anki/__init__.py at line 14. Now looking at that file we can see that the exception is raised whenever the function sys.getfilesystemencoding().lower() returns the string ascii or ansi_x3.4-1968:

/usr/share/anki/anki/__init__.py lines 9:14 wrote:
if sys.version_info[0] > 2:
    raise Exception("Anki should be run with Python 2")
elif sys.version_info[1] < 6:
    raise Exception("Anki requires Python 2.6+")
elif sys.getfilesystemencoding().lower() in ("ascii", "ansi_x3.4-1968"):
    raise Exception("Anki requires a UTF-8 locale.")

However this output

charli3 wrote:
$ python2 -c "import sys; print sys.getfilesystemencoding()"
UTF-8

shows that the function sys.getfilesystemencoding() returns UTF-8 and thus the exception shouldn't occur hmm

Did you execute anki in a terminal different from the one in wich you executed the command I posted? Can you please try again to run this commands

python2 -c "import sys; print sys.getfilesystemencoding()" && anki

and see what happen?

PS:

charli3 wrote:

(Is that Spock piped through Sherlock with Holmes args?)

I think you're right lol


About me - github

-- When you have eliminated the impossible, whatever remains, however improbable, must be the truth -- Spock | Sherlock Holmes

Offline

#9 2015-06-10 00:51:22

charli3
Member
Registered: 2015-06-01
Posts: 45

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

It was the same terminal I believe.

$ python2 -c "import sys; print sys.getfilesystemencoding()" && anki
UTF-8

Not sure what changed...Anki is now running without error.  Thanks for your help mauritiusdadd!

Last edited by charli3 (2015-06-10 01:02:54)

Offline

#10 2018-07-06 02:15:58

djradnad
Member
Registered: 2018-07-06
Posts: 1

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

I am getting the same error when trying to run anki. I am using ubuntu on a chromebook, so that may be the problem lol, but i tried your commands and the output wasnt quite the same as the OP, if your still around after 3 years.

I just installed ubuntu today, so uber noob right now.

troubleshooting go!

Offline

#11 2018-07-06 02:48:23

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] error when tried to run Anki "requires a UTF-8 locale"

djradnad wrote:

I am using ubuntu on a chromebook, so that may be the problem lol

Did you not read the notice when you signed up, or did you choose to ignore it? We only support Arch. https://wiki.archlinux.org/index.php/Co … pport_ONLY


troubleshooting go!

Not happening.



Closing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB