Ask Your Question
1

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

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

venkateshsampath gravatar image

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

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 'run_tests.sh' 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/__init__.py

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/utrunner.py /home/venkat/workspace/temp/python/openstack/glance/glance/tests/unit/test_policy.py true

Testing started at 6:22 PM ...

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

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

File "/home/venkat/workspace/temp/python/openstack/glance/glance/tests/unit/test_policy.py", 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/policy.py", 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/exception.py", 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/exception.py", 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

Comments

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 -0500 )edit

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

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

1 answer

Sort by ยป oldest newest most voted
0

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

I get same issue

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

Stats

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

Seen: 3,476 times

Last updated: Dec 19 '13