Ask Your Question

NameError: name '_' is not defined (related gettext & _() method)

asked 2013-06-13 22:37:08 -0600

venkateshsampath gravatar image

updated 2013-06-13 22:40:06 -0600

Has anyone encountered this error.

I got it when I was trying to run some unit tests from Pycharm IDE. The stack trace is included below.

Question: #1 If I run my tests using '' or 'nosetests -v' I am not getting this error. why is the error doesn't get thrown in these cases?

Question: #2 I managed to fix the problem by including the following lines in glance/

from glance.openstack.common import gettextutils gettextutils.install('glance')

Is it a right fix?

------------------------- exception stack trace --------------------------------- /usr/bin/python /home/venkat/workspace/installs/pycharm-2.7.2/helpers/pycharm/ /home/venkat/workspace/temp/python/openstack/glance/glance/tests/unit/ true

Testing started at 6:22 PM ...

Traceback (most recent call last): File "/home/venkat/workspace/installs/pycharm-2.7.2/helpers/pycharm/", line 110, in <module> modules = [loadSource(a[0])]

File "/home/venkat/workspace/installs/pycharm-2.7.2/helpers/pycharm/", line 34, in loadSource module = imp.load_source(moduleName, fileName)

File "/home/venkat/workspace/temp/python/openstack/glance/glance/tests/unit/", line 20, in <module> import glance.api.policy

File "/usr/local/lib/python2.7/dist-packages/glance-2013.2.a9.gfdf81b2-py2.7.egg/glance/api/", line 25, in <module> from glance.common import exception

File "/usr/local/lib/python2.7/dist-packages/glance-2013.2.a9.gfdf81b2-py2.7.egg/glance/common/", line 31, in <module> class GlanceException(Exception):

File "/usr/local/lib/python2.7/dist-packages/glance-2013.2.a9.gfdf81b2-py2.7.egg/glance/common/", line 39, in GlanceException message = _("An unknown exception occurred")

NameError: name '_' is not defined

Process finished with exit code 1

------------------------- exception stack trace ---------------------------------

edit retag flag offensive close merge delete


Hi, Were you able to fix the issue? I would also suggest if you have not, then try posting the question on openstack-dev mailing list.

koolhead17 gravatar imagekoolhead17 ( 2013-08-12 15:37:09 -0600 )edit

I encountered a similar problem and applied your "fix" which seems to work. +1

moje gravatar imagemoje ( 2013-10-17 14:55:34 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-12-19 03:54:20 -0600

I get same issue

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools


Asked: 2013-06-13 22:37:08 -0600

Seen: 3,912 times

Last updated: Dec 19 '13