开发者

Sync django-piston models when using egg module

I'm using django-piston and running into the following problem when running开发者_如何转开发 the manage.py syncdb command:

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__'

In my development environment, I don't have this problem. There I have my python path set to include the django-piston directory. On production, I installed piston by compiling it to an rpm (python setup.py bdist --format=rpm) and installing it as an egg in /usr/lib/python2.6/site-packages/. This means that in development, I can do

>>> import piston
>>> piston.__file__
/some/file/path/here

But on production I get

>>> import piston
>>> piston.__file__
AttributeError: 'module' object has no attribute '__file__'

Does anyone know a way around this?


Looks like this is a known issue with Piston 0.2.3. You could apply this patch or just use version 0.2.2 by installing it as so:

pip install django-piston==0.2.2


I had the same issue, not sure what caused it, but to fix it, I uncommented the piston app out of my INSTALLED_APPS in settings, and it started working again, so it was something to do with loading piston. I'm going to remove piston from my site-packages directory and try to reload it, and see if that helps.

Also, while trying to find the answer to my question I came across a few sites with similar issues.

This site describes an issue related to __init__.py missing.

http://www.willmer.com/kb/2007/12/attributeerror-module-object-has-no-attribute-blah/

This site describes circular imports as an issue.

http://www.answermysearches.com/python-fixing-module-object-has-no-attribute/333/

And another one that I can't find, mentioned something about not being able to load the files correctly from an app installed as an egg.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜