使用egg modu时同步Djangostain模型

2024-04-26 12:52:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用django活塞,在运行管理.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活塞目录。在生产过程中,我将活塞编译为rpm(python setup.py bdist --format=rpm),并将其作为一个鸡蛋安装在/usr/lib/python2.6/site-packages/中。这意味着在开发过程中,我可以

^{pr2}$

但在制作上

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

有人知道怎么解决这个问题吗?在


Tags: djangoinpyhometransexecutesettingsline
2条回答

看起来这是一个活塞0.2.3的known issue。您可以应用this patch或只使用0.2.2版本,方法是这样安装:

pip install django-piston==0.2.2

我也遇到了同样的问题,不知道是什么原因造成的,但是为了解决这个问题,我在“设置”中取消了活塞应用程序的注释,它又开始工作了,所以这与加载活塞有关。如果我想从我的网站上重新加载并删除我的程序包。在

另外,在试图找到我问题的答案时,我遇到了一些类似问题的网站。在

此网站描述了一个与__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/

另一个我找不到的,提到了无法从一个以鸡蛋的形式安装的应用程序中正确加载文件的问题。在

相关问题 更多 >