使用egg模块时同步django活塞模型
我正在使用 django-piston 并在运行manage.pysyncdb命令时遇到以下问题:
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
) 并将其作为 Egg 安装在 /usr/lib/python2.6/ 中来安装活塞站点包/
。这意味着在开发中,我可以做
>>> import piston
>>> piston.__file__
/some/file/path/here
但是在生产中我得到
>>> import piston
>>> piston.__file__
AttributeError: 'module' object has no attribute '__file__'
有人知道解决这个问题的方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来这是 Piston 0.2.3 的已知问题。您可以应用此补丁或仅使用0.2.2 版,安装如下:
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:
我遇到了同样的问题,不确定是什么原因造成的,但为了解决这个问题,我在设置中取消了 INSTALLED_APPS 中活塞应用程序的注释,然后它再次开始工作,所以这与加载活塞有关。我将从我的站点包目录中删除活塞并尝试重新加载它,看看是否有帮助。
另外,在试图找到我的问题的答案时,我遇到了一些存在类似问题的网站。
此站点描述了与
__init__.py
缺失相关的问题。http://www.willmer。 com/kb/2007/12/attributeerror-module-object-has-no-attribute-blah/
该网站将循环导入描述为一个问题。
http://www.answermysearches.com/python- Fixing-module-object-has-no-attribute/333/
还有一个我找不到的,提到了无法从作为 Egg 安装的应用程序正确加载文件。
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.