我正在使用 django-piston 并在运行 manage.py syncdb 命令时遇到以下问题:
Traceback (most recent call last):
File "./manage.py", line 13, in <module>
execute_manager(settings)
File "/home/appfirst/django/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
............ lines ommitted ...........
File "/home/appfirst/django/django/utils/translation/trans_real.py", line 176, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/appfirst/django/django/utils/translation/trans_real.py", line 160, in _fetch
apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
AttributeError: 'module' object has no attribute '__file__'
在我的开发环境中,我没有这个问题。在那里,我将 python 路径设置为包含 django-piston 目录。在生产中,我通过将活塞编译为 rpm ( python setup.py bdist --format=rpm
) 并将其作为鸡蛋安装在/usr/lib/python2.6/site-packages/
. 这意味着在开发中,我可以做
>>> import piston
>>> piston.__file__
/some/file/path/here
但在生产中我得到
>>> import piston
>>> piston.__file__
AttributeError: 'module' object has no attribute '__file__'
有谁知道解决这个问题的方法?