如何识别AttributeError:'module'所指的包?

时间:2013-02-27 20:43:14

标签: python pyramid

我正在尝试移动我正在从一台服务器写到另一台服务器的Python金字塔应用程序。我从源代码管理中检查了代码并运行了python setup.py develop来准备环境,但是当我尝试运行pserve development.ini时,我得到以下回溯:

2013-02-27 20:38:20,269 INFO  [pyramid_scss][MainThread] adding asset path /home/pgrace/repos/Asterisk-WebApps/Cedar-Root/opt/cedar/cedar/assets/scss
Traceback (most recent call last):
  File "/home/pgrace/venvs/pyramid/bin/pserve", line 8, in <module>
    load_entry_point('pyramid==1.4', 'console_scripts', 'pserve')()
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/scripts/pserve.py", line 50, in main
    return command.run()
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/scripts/pserve.py", line 304, in run
    global_conf=vars)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/scripts/pserve.py", line 328, in loadapp
    return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/util.py", line 56, in fix_call
    val = callable(*args, **kw)
  File "/home/pgrace/repos/Asterisk-WebApps/Cedar-Root/opt/cedar/cedar/__init__.py", line 18, in main
    config.include("pyramid_scss")
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/config/__init__.py", line 773, in include
    c(configurator)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid_scss/__init__.py", line 88, in includeme
    scss.LOAD_PATHS = ','.join([scss.LOAD_PATHS, ','.join(load_paths)])
AttributeError: 'module' object has no attribute 'LOAD_PATHS'

现在,我可以告诉问题来自pyramid_scss,但就我所知它引用的代码而言,就好像module类不包含LOAD_PATHS指令一样。我正在试图弄清楚它所指的是哪个模块,以便我可以追踪我是否缺少依赖关系或其他东西。有没有人有任何想法我如何确定module引用指向的位置,以便我可以检查该代码?

编辑: 错误出现在includeme定义中,每次特定于金字塔的包被实例化时,我自己都会自动包含这个错误?也许?无论如何,它说scss.LOAD_PATHS不存在,是的,但是在pyramid_scsspyScss包中没有scss类,这让我想知道是否还有其他一些类是迟到的什么的。

def includeme(config):
    load_paths, static_path = _get_import_paths(config.registry.settings)
    scss.LOAD_PATHS = ','.join([scss.LOAD_PATHS, ','.join(load_paths)])
    scss.STATIC_ROOT = static_path
    config.add_renderer('scss', renderer_factory)

pyScss中的Scss类确实包含一个LOAD_PATHS指令,但是我没有看到对象scss绑定到Scss类定义的位置。我想知道上面的def includeme中是否有遗漏可能是答案的一部分,但是它引出了一个问题 - 这在另一台机器上运行正常,为什么要现在休息?还有其他一些东西缺失,我只是没有接受。

2 个答案:

答案 0 :(得分:3)

通过检查scss包的代码,看起来LOAD_PATHS全局变量可能已从__init__.py移至config.py

因此,如果您想尝试修复pyramid_scss应用,可以将pyramid_scss/__init__.py的第88行更改为:

scss.config.LOAD_PATHS = ','.join([scss.config.LOAD_PATHS, ','.join(load_paths)])

答案 1 :(得分:2)

一行但最后一行告诉你哪个模块受到影响:

    scss.LOAD_PATHS = ','.join([scss.LOAD_PATHS, ','.join(load_paths)])
AttributeError: 'module' object has no attribute 'LOAD_PATHS'

因此scss模块没有LOAD_PATHS属性。