python - 使用 egg 模块时同步 django-piston 模型

标签 python django django-piston

我正在使用 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/中来安装站点包/。这意味着在开发中,我可以做

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

但是在生产中我得到了

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

有人知道解决这个问题的方法吗?

最佳答案

看起来这是一个 known issue活塞 0.2.3。你可以申请this patch或者只使用 0.2.2 版本安装它:

pip install django-piston==0.2.2

关于python - 使用 egg 模块时同步 django-piston 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5735237/

相关文章:

python - 如何使用Python套接字连接到同一网络上的另一台计算机

python - Django 测试框架中的 login()

django - 'HttpResponse' 没有属性 '_get_content

python - 在django View 函数中调用活塞处理程序

python - 在 python 脚本中隐藏导入时的警告消息

python - 正确的 xpath 来卷起子项的文本

django - 无法使用 View 名称 (django-rest-framework) 解析超链接关系的 URL

Django1.6 transaction.atomic 问题

python - 有没有比 `except: pass` 更简洁的替代品?