ImportError: No module named app_factory

ImportError: No module named app_factory

在運行python的一個wsgi相關的程序時,出現下列錯誤:python

cast503@cast503-OptiPlex-7010:~/python$ python wsgi_paste.pyapi

Traceback (most recent call last):app

  File "wsgi_paste.py", line 13, in <module>python2.7

    wsgi_app = loadapp('config:'+ini_path)spa

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 247, in loadappci

    return loadobj(APP, uri, name=name, **kw)get

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 271, in loadobjstring

    global_conf=global_conf)it

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 296, in loadcontextio

    global_conf=global_conf)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig

    return loader.get_context(object_type, name, global_conf)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 458, in get_context

    section)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 517, in _context_from_explicit

    value = import_string(found_expr)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 22, in import_string

    return pkg_resources.EntryPoint.parse("x=" + s).load(False)

  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load

    entry = __import__(self.module_name, globals(),globals(), ['__name__'])

  File "/home/cast503/python/wsgi_paste.py", line 13, in <module>

    wsgi_app = loadapp('config:'+ini_path)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 247, in loadapp

    return loadobj(APP, uri, name=name, **kw)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 271, in loadobj

    global_conf=global_conf)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext

    global_conf=global_conf)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig

    return loader.get_context(object_type, name, global_conf)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 458, in get_context

    section)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 517, in _context_from_explicit

    value = import_string(found_expr)

  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 22, in import_string

    return pkg_resources.EntryPoint.parse("x=" + s).load(False)

  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load

    entry = __import__(self.module_name, globals(),globals(), ['__name__'])

ImportError: No module named app_factory

根據錯誤提示一直在網上搜app_factory模塊,沒有找到,最後仔細查看代碼,發如今項目配置文件api-paste.ini中將「:」寫成了「.」。

正確配置應該是:

[app:hello]

paste.app_factory = app:app_factory

錯誤配置:

[app:hello]

paste.app_factory = app.app_factory

相關文章
相關標籤/搜索