私は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__'
私の開発環境では、この問題はありません。そこで、django-piston ディレクトリを含むように python パスを設定しました。本番では、ピストンを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__'
誰もこれを回避する方法を知っていますか?