Invalid currency locale specified for SHOP_CURRENCY_LOCALE

609 views
Skip to first unread message

Eric Boo

unread,
Jul 4, 2014, 3:51:38 AM7/4/14
to mezzani...@googlegroups.com
Hi,

I just tried to set up a dev server on a new VPS and am seeing the following when I run ./manage.py runserver

django.core.exceptions.ImproperlyConfigured: Invalid currency locale specified for SHOP_CURRENCY_LOCALE: 'en_US.ISO8859-1'. You'll need to set the locale for your system, or configure the SHOP_CURRENCY_LOCALE setting in your settings module.


I have these in my environment:

declare -x LC_CTYPE="en_US.ISO8859-1"
declare -x LOCALE="en_US.ISO8859-1"


This is the same even if I change the SHOP_CURRENCY_LOCALE to en_US.UTF-8, or en_GB.UTF-8 and when I change the environment variables accordingly.

Any ideas?


Eric

Eric Boo

unread,
Jul 4, 2014, 3:53:12 AM7/4/14
to mezzani...@googlegroups.com
Just a note:
locale -a has 

en_US.ISO8859-1
en_US.ISO8859-15
en_US.UTF-8
en_GB.ISO8859-1
en_GB.ISO8859-15
en_GB.UTF-8

Ken Bolton

unread,
Jul 4, 2014, 8:46:23 AM7/4/14
to mezzanine-users
Hi Eric,

Mezzanine's Fabric script, fabfile.py, has code that sets the locale properly. Search for the string "locale" in https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/project_template/fabfile.py.

Your initial email is a little vague. Are you running a Django development server, aka "runserver"? Or are you running a development server identical to your final deployed production server?

ken


--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Boo

unread,
Jul 4, 2014, 9:14:02 AM7/4/14
to mezzani...@googlegroups.com
Hi Ken,

Thanks for your reply.

I git cloned my live site’s code to a new development server so that I can add some more features, and at the same time test it out on a BSD OS (live site’s running Debian).

Running the site via gunicorn gave me the locale error, so I tried running it as ./manage.py runserver to see if it made a difference. In this case the error was the same.

On the live server, Django + Cartridge + Mezzanine is using “en_GB” for the locale but for some reason it’s not available on the development machine. 

locale -a doesn’t list either “en_US” or “en_GB”, but rather:
en_US.ISO8859-1
en_US.ISO8859-15
en_US.UTF-8
en_GB.ISO8859-1
en_GB.ISO8859-15
en_GB.UTF-8

Therefore one-by-one, I tried setting SHOP_CURRENCY_LOCALE to each of the above and exporting LOCAL and LC_CTYPE to the same, without success.

Initially I suspected that it’ll only work with en_GB and en_US without the suffixes (eg en_US.UTF-8) but I see on the fabfile.py that "en_US.UTF-8” is being used.

Still not sure what to do.

Cartridge, Mezzanine and Django are up to date on the dev machine.

-- 
Eric Boo
Sent with Airmail
You received this message because you are subscribed to a topic in the Google Groups "Mezzanine Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/ahNvEvQkV8s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mezzanine-use...@googlegroups.com.

Ken Bolton

unread,
Jul 4, 2014, 9:54:44 AM7/4/14
to mezzanine-users
Hi Eric,

Look inline below.

On Fri, Jul 4, 2014 at 9:13 AM, Eric Boo <eri...@gmail.com> wrote:
I git cloned my live site’s code to a new development server so that I can add some more features, and at the same time test it out on a BSD OS (live site’s running Debian).

I would keep development and platform migration on separate machine instances. Dev/prod parity!

To make life easier, consider using Vagrant for development work. It is cheap, local, and portable.

Running the site via gunicorn gave me the locale error, so I tried running it as ./manage.py runserver to see if it made a difference. In this case the error was the same.

Try `python manage.py shell`, or `shell_plus` if you have the excellent django-extensions installed. Below are my results for an ancient Cartridge site.

>>> from mezzanine.conf import settings
>>> settings.SHOP_CURRENCY_LOCALE
"en_US.UTF-8"

hth,
ken

Eric Boo

unread,
Jul 4, 2014, 11:39:02 AM7/4/14
to mezzani...@googlegroups.com
Hi Ken,

Oh well, manage.py shell gives me:

django.core.exceptions.ImproperlyConfigured: Invalid currency locale specified for SHOP_CURRENCY_LOCALE: 'en_US.UTF-8'. You'll need to set the locale for your system, or configure the SHOP_CURRENCY_LOCALE setting in your settings module.


I wonder if it’s possible to run Mezzanine + Cartridge inside OpenBSD at all, but given that we’re talking about Python, it shouldn’t be an issue, right?

-- 
Eric Boo
Sent with Airmail

Ken Bolton

unread,
Jul 4, 2014, 11:45:14 AM7/4/14
to mezzanine-users
Go ahead and set SHOP_CURRENCY_LOCALE in your settings file. I fear, though, that this error is hiding something in your configuration that is wrong and should be fixed.

No reason this shouldn't work on OpenBSD. FWIW, OpenBSD was my OS of choice until Ubuntu became de facto standard.

 I think there may be some value in documenting (that is, writing Fabric scripts) for each of the major systems. The Debian family is well covered by the current fabfile.py. All we need are motivated individuals who need reliable deployments on CentOS and the BSD family.

ken


--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.

Eric Boo

unread,
Jul 4, 2014, 11:55:46 AM7/4/14
to mezzani...@googlegroups.com
Good to know that it should work on OpenBSD. I really want to get to the bottom of this.

I have tried placed the following in either local_settings.py or settings.py:

SHOP_CURRENCY_LOCALE = 'en_US.UTF-8'

SHOP_USE_RATINGS = False


These are the exact same local_settings.py and settings.py files that I’m successfully using on my live machine.

May be an overkill, but maybe it’ll be interesting to see if the exact same files work on a FreeBSD machine instead.

-- 
Eric Boo
Sent with Airmail

Ken Bolton

unread,
Jul 4, 2014, 12:17:37 PM7/4/14
to mezzanine-users
With those settings you still get the error the ImproperlyConfigured error? Your system and/or application is improperly configured. Back out or start over. You have been automating as you go, right?

ken

Eric Boo

unread,
Jul 4, 2014, 12:40:29 PM7/4/14
to mezzani...@googlegroups.com
I will set up a new openbsd virtual machine to test, although this dev machine is pretty new as well. Just set it up a few days ago without much on it at the moment. Weirdness.

Sent from my iPad

Ken Bolton

unread,
Jul 4, 2014, 1:01:40 PM7/4/14
to mezzanine-users
In case you missed this, in which Apache is being used and requires additional coaxing: https://groups.google.com/forum/#!topic/mezzanine-users/cC7HwtioyKE.

Writers to this mailing list are urged to provide the details of any variation between the installation under question and the deployment documentation at http://mezzanine.jupo.org/docs/deployment.html.

Eric Boo

unread,
Jul 4, 2014, 10:10:40 PM7/4/14
to mezzani...@googlegroups.com
Hi,

I’ve just set up a brand new OpenBSD 5.5 virtual machine to test.

Then I used mkvirtualenv to create a place to store my test files.

And then I copied exactly the instructions on http://cartridge.jupo.org/overview.html#installation  in order to create a brand new cartridge installation. 

When I got to this:

mezzanine-project -a cartridge project_name 
cd project_name 
python manage.py createdb —noinput

Then I get the following error:

(test)-bash-4.2# python manage.py createdb --noinput

/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/conf.py:51: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.

  warn("You haven't defined the ALLOWED_HOSTS settings, which "

/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: Asia/Singapore

  warn("TIME_ZONE setting is not set, using closest match: %s" % tz)

/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/conf.py:92: UserWarning: mezzanine.pages.context_processors.page is required in the TEMPLATE_CONTEXT_PROCESSORS setting. Adding it now, but you should update settings.py to explicitly include it.

  "explicitly include it." % cp)

Traceback (most recent call last):

  File "manage.py", line 29, in <module>

    execute_from_command_line(sys.argv)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line

    utility.execute()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command

    klass = load_command_class(app_name, subcommand)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class

    module = import_module('%s.management.commands.%s' % (app_name, name))

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module

    __import__(name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/core/management/__init__.py", line 16, in <module>

    from mezzanine.utils.tests import copy_test_to_media

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/tests.py", line 17, in <module>

    User = get_user_model()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 127, in get_user_model

    user_model = get_model(app_label, model_name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/db/models/loading.py", line 271, in get_model

    self._populate()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _populate

    self.load_app(app_name, True)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app

    models = import_module('%s.models' % app_name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module

    __import__(name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/models.py", line 48, in <module>

    class Priced(models.Model):

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/models.py", line 54, in Priced

    unit_price = fields.MoneyField(_("Unit price"))

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/fields.py", line 46, in __init__

    set_locale()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/utils.py", line 146, in set_locale

    raise ImproperlyConfigured(msg % currency_locale)

django.core.exceptions.ImproperlyConfigured: Invalid currency locale specified for SHOP_CURRENCY_LOCALE: ''. You'll need to set the locale for your system, or configure the SHOP_CURRENCY_LOCALE setting in your settings module.

(test)-bash-4.2# 



And this is what locales I have:

(test)-bash-4.2# locale -a|grep en_US

en_US.ISO8859-1

en_US.ISO8859-15

en_US.UTF-8



Then I added this to settings.py:

SHOP_CURRENCY_LOCALE="en_US.UTF-8"



And I get this:

(test)-bash-4.2# python manage.py createdb --noinput

/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/conf.py:51: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.

  warn("You haven't defined the ALLOWED_HOSTS settings, which "

/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: Asia/Singapore

  warn("TIME_ZONE setting is not set, using closest match: %s" % tz)

/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/conf.py:92: UserWarning: mezzanine.pages.context_processors.page is required in the TEMPLATE_CONTEXT_PROCESSORS setting. Adding it now, but you should update settings.py to explicitly include it.

  "explicitly include it." % cp)

Traceback (most recent call last):

  File "manage.py", line 29, in <module>

    execute_from_command_line(sys.argv)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line

    utility.execute()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command

    klass = load_command_class(app_name, subcommand)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class

    module = import_module('%s.management.commands.%s' % (app_name, name))

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module

    __import__(name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/core/management/__init__.py", line 16, in <module>

    from mezzanine.utils.tests import copy_test_to_media

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/mezzanine/utils/tests.py", line 17, in <module>

    User = get_user_model()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 127, in get_user_model

    user_model = get_model(app_label, model_name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/db/models/loading.py", line 271, in get_model

    self._populate()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _populate

    self.load_app(app_name, True)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app

    models = import_module('%s.models' % app_name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module

    __import__(name)

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/models.py", line 48, in <module>

    class Priced(models.Model):

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/models.py", line 54, in Priced

    unit_price = fields.MoneyField(_("Unit price"))

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/fields.py", line 46, in __init__

    set_locale()

  File "/root/.virtualenvs/test/lib/python2.7/site-packages/cartridge/shop/utils.py", line 146, in set_locale

    raise ImproperlyConfigured(msg % currency_locale)

django.core.exceptions.ImproperlyConfigured: Invalid currency locale specified for SHOP_CURRENCY_LOCALE: 'en_US.UTF-8'. You'll need to set the locale for your system, or configure the SHOP_CURRENCY_LOCALE setting in your settings module.



Any thoughts?

-- 
Eric Boo
Sent with Airmail

Eric Boo

unread,
Jul 5, 2014, 6:50:30 AM7/5/14
to mezzani...@googlegroups.com
Not sure if this is a python bug, or opensd bug:

(test)-bash-4.2# python2.7

Python 2.7.6 (default, Mar  4 2014, 10:29:45) 

[GCC 4.2.1 20070719 ] on openbsd5

Type "help", "copyright", "credits" or "license" for more information.

>>> import locale

>>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') ## This works

'C/en_US.UTF-8/C/C/C/en_US.UTF-8'

>>> locale.setlocale(locale.LC_MONETARY, 'en_US.UTF-8') ## This does not work 

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/local/lib/python2.7/locale.py", line 547, in setlocale

    return _setlocale(category, locale)

locale.Error: unsupported locale setting


Ken Bolton

unread,
Jul 5, 2014, 8:49:32 AM7/5/14
to mezzanine-users
Hi Eric,

I just created an OpenBSD 5.3 Vagrant instance to try to help you out.

$ sudo pkg_add py-virtualenv
$ virtualenv test
$ source test/bin/activate
$ pip install -U cartridge

Installing cartridge fails when trying to install the Pillow/PIL requirements with the following error:
ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.

Allegedly, this is resolved in OpenBSD 5.4, but the only Vagrant box I can find with 5.4 is too big for me my current drive setup.

ken

nathan

unread,
Jul 5, 2014, 10:44:14 PM7/5/14
to mezzani...@googlegroups.com
I remember openbsd needing some settings changed (set) in the .profile file. It's an export of LC_TYPE. When you log in as a user out will set the locale. I'm not sure if this is necessary anymore. It it's in the all-knowing FAQ.

nathan

unread,
Jul 6, 2014, 7:40:40 PM7/6/14
to mezzani...@googlegroups.com


On Saturday, July 5, 2014 10:44:14 PM UTC-4, nathan wrote:
I remember openbsd needing some settings changed (set) in the .profile file.  It's an export of LC_TYPE.  When you log in as a user out will set the locale. I'm not sure if this is necessary anymore. It it's in the all-knowing FAQ.  That would be the openbsd faq.

Eric Boo

unread,
Jul 6, 2014, 10:58:32 PM7/6/14
to mezzani...@googlegroups.com
I'll test it with an older version of OpenBSD later, but on OpenBSD 5.5, it looks like LC_MONETARY may be limited. From man setlocale:

>>Use of LC_MONETARY could lead to misleading results until we have a real time currency conversion function.

Eric Boo

unread,
Jul 6, 2014, 11:20:16 PM7/6/14
to mezzani...@googlegroups.com
Hi Ken,

Thanks for trying. I just downloaded the iso for OpenBSD 5.3 and installed it. The result is the same.

In python, locale.setlocale(locale.LC_MONETARY, "en_GB.UTF-8") also throws an exception.

Looks like it only accepts "C", and "POSIX".
Reply all
Reply to author
Forward
0 new messages