Problem with Locale when initializing a Nikola project

133 views
Skip to first unread message

Luca Cerone

unread,
May 25, 2014, 9:56:50 AM5/25/14
to nikola-...@googlegroups.com
Dear all,
I would like to start a blog and after a few thinking I decided I wanted a static blog,
and that I want to use a Python based static site generator. Adfter a few reading I would like to use Nikola, 
so today I have installed Nikola on my Arch distribution with Python 3.4 using pip
(note, this won't be my production server, I just wanted to try it a bit on my own laptop):

pip install nikola[extras,tests]

The installation seems to have happened without issues.

I then tried to create my blog using:

nikola init mysite

This however fails with the message:

[2014-05-25T13:37:38Z] WARNING: Nikola: Could not guess locale for language en, using locale C
Traceback (most recent call last):
  File "/home/luca/.local/bin/nikola", line 9, in <module>
    load_entry_point('Nikola==7.0.0', 'console_scripts', 'nikola')()
  File "/home/luca/.local/lib/python3.4/site-packages/nikola/__main__.py", line 124, in main
    site = Nikola(**config)
  File "/home/luca/.local/lib/python3.4/site-packages/nikola/nikola.py", line 517, in __init__
    self.plugin_manager.collectPlugins()
  File "/home/luca/.local/lib/python3.4/site-packages/yapsy/PluginManager.py", line 527, in collectPlugins
    self.locatePlugins()
  File "/home/luca/.local/lib/python3.4/site-packages/yapsy/PluginManager.py", line 442, in locatePlugins
    self._candidates, npc = self.getPluginLocator().locatePlugins()
  File "/home/luca/.local/lib/python3.4/site-packages/yapsy/PluginFileLocator.py", line 430, in locatePlugins
    plugin_info = self._getInfoForPluginFromAnalyzer(analyzer, dirpath, filename)
  File "/home/luca/.local/lib/python3.4/site-packages/yapsy/PluginFileLocator.py", line 384, in _getInfoForPluginFromAnalyzer
    plugin_info_dict,config_parser = analyzer.getInfosDictFromPlugin(dirpath, filename)
  File "/home/luca/.local/lib/python3.4/site-packages/yapsy/PluginFileLocator.py", line 264, in getInfosDictFromPlugin
    raise ValueError("Missing *name* of the plugin in extracted infos.")
ValueError: Missing *name* of the plugin in extracted infos.


I asked on Gihub and @Kwpolska told me he could reproduce the issue and that this is due to my locale settings/

After checking I think that my locale is configured correctly, but it still doesn't work, though.

The output of locale -a is:

C
en_GB.utf8
POSIX

while the output of locale is:
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

Searching for possible errors with nikola and locale I found this post (https://github.com/getnikola/nikola/issues/949)
where it is said that the error is due to the fact that LC_ALL is empty.

So I set LC_ALL like this: export LC_ALL="en_GB.UTF-8"
and the output of locale is now in fact:
locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=en_GB.UTF-8

I then tried to create my site again (nikola init mysite)
but I keep getting the same error.

Could you please help me to understand if my locale is set correctly? or if I am doing something wrong
with the initialization of my nikola blog.

Thanks a lot in advance to all of you for the help!

Cheers,
Luca

Chris “Kwpolska” Warrick

unread,
May 25, 2014, 10:28:19 AM5/25/14
to Nikola—Discuss
On Sun, May 25, 2014 at 3:56 PM, Luca Cerone <luca....@gmail.com> wrote:
> The output of locale -a is:
>
> C
> en_GB.utf8
> POSIX
>

You are missng en_US.utf8. Nikola requires that.

Right now, you can:

(a) generate en_US.utf8 — and possibly fix some problems in other apps; or
(b) apply the patch that closed the issue (4eceba6), initialize a new
site without any problems* (and in your resulting site set
LOCALE_DEFAULT='en_GB.utf8' (or the LOCALES dict if using multiple
languages)

* assuming you aren’t curious enough to ask for supported languages —
in which case you must also apply 73d14f8.

--
Chris “Kwpolska” Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense

Luca Cerone

unread,
May 25, 2014, 10:47:37 AM5/25/14
to nikola-...@googlegroups.com

You are missng en_US.utf8.  Nikola requires that.

thanks, I didn't understand that!
 

Right now, you can:

(a) generate en_US.utf8 — and possibly fix some problems in other apps; or

This is probably what I will do (I would like to work only with the stable branch for the moment,
and get into the hacking development, when I have some familiarity with Nikola)
 
(b) apply the patch that closed the issue (4eceba6), initialize a new
site without any problems* (and in your resulting site set
LOCALE_DEFAULT='en_GB.utf8' (or the LOCALES dict if using multiple
languages)

* assuming you aren’t curious enough to ask for supported languages  —
in which case you must also apply 73d14f8.

As I never had to work with locales in my apps/scripts, this is all a bit new to me.
Can you clarify me a bit why the US locale is needed (what if for example I want to start a blog in Italian
in an environment where the language and the locale is Italian?)

As for patch (4eceba6): you mention the files have to be ascii only. Is this only needed when the locale is not set properly to
en_US? 
I am curious enough to to know about supported languages :)

Will these two patches be put in master and on PyPI soon???

Thanks a lot for all the clarifications :)

Luca Cerone

unread,
May 25, 2014, 11:10:53 AM5/25/14
to nikola-...@googlegroups.com
Anyway setting the en_US.utf8 locale fixed the issues.

For those having the same issue, you need to uncomment the line with "en_US.UTF-8 UTF-8"
in your locale.gen file (in arch this is /etc/locale.gen).

Next you have to run (as root) locale-gen

After doing that nikola works as intended.

Thanks again to Chris for the help (both here and on github)

Chris “Kwpolska” Warrick

unread,
May 25, 2014, 11:14:25 AM5/25/14
to Nikola—Discuss
On Sun, May 25, 2014 at 4:47 PM, Luca Cerone <luca....@gmail.com> wrote:
> This is probably what I will do (I would like to work only with the stable
> branch for the moment,
> and get into the hacking development, when I have some familiarity with
> Nikola)

The patch is literally this:

sed 's/á/a/' nikola/plugins/compile/ipynb.plugin

Not really “hacking”, is it?

> As I never had to work with locales in my apps/scripts, this is all a bit
> new to me.
> Can you clarify me a bit why the US locale is needed (what if for example I
> want to start a blog in Italian
> in an environment where the language and the locale is Italian?)

It’s needed because we default to it, and then try to do Unicode-based
operations, while the C locale makes you use ascii only. Create a
site that uses Italian only and you don’t need it anymore (or avoid
Unicode things before that happens)

This can be problematic though, attempt to fix it:
https://github.com/getnikola/nikola/pull/1305

> As for patch (4eceba6): you mention the files have to be ascii only. Is this
> only needed when the locale is not set properly to
> en_US?
> I am curious enough to to know about supported languages :)

Those are internal files, and it doesn’t matter for user input (which
has to be utf-8 no matter what) — though yes, the bug appears only if
you were on the C locale.

> Will these two patches be put in master and on PyPI soon???

Both are on master, which we consider “shippable”; however, it will
take some time till the next release.

Luca Cerone

unread,
May 25, 2014, 11:24:54 AM5/25/14
to nikola-...@googlegroups.com
>
> The patch is literally this:
>
> sed 's/á/a/' nikola/plugins/compile/ipynb.plugin
>
> Not really “hacking”, is it?
>

No :) what I meant is that for the moment I prefer to use the
distribution only available in pip.
When I'll get more comfortable with how nikola works and how is
implemented, I'd like to fork
the github repository and hopefully contribute if I am able.

>
> It’s needed because we default to it, and then try to do Unicode-based
> operations, while the C locale makes you use ascii only. Create a
> site that uses Italian only and you don’t need it anymore (or avoid
> Unicode things before that happens)
>

Thanks, I think I get it now.

> This can be problematic though, attempt to fix it:
> https://github.com/getnikola/nikola/pull/1305
>
>> As for patch (4eceba6): you mention the files have to be ascii only. Is this
>> only needed when the locale is not set properly to
>> en_US?
>> I am curious enough to to know about supported languages :)
>
> Those are internal files, and it doesn’t matter for user input (which
> has to be utf-8 no matter what) — though yes, the bug appears only if
> you were on the C locale.
>

Hopefully I'll get this when I'll get more familiar with Nikola :D

Thanks again :)
Reply all
Reply to author
Forward
0 new messages