Jinja 2 x python setup.py安装--old-and-unmanageable

时间:2014-11-02 12:37:27

标签: python python-3.x flask jinja2 setuptools

我有一个名为' htpwd'这是一个python / flask项目。

当我使用python setup.py开发时,项目效果很好,我可以看到我的页面并使用它。

当我使用python setup.py install安装项目时,会发生以下错误:

NotADirectoryError: [Errno 20] Not a directory: '/home/arthas/htpwd/lib/python3.4/site-packages/htpwd-0.2.0-py3.4.egg/htpwd/templates/index.html'

完整的追溯在下面。

正如我所看到的,问题与以下事实有关:项目没有作为默认的python包安装,而是作为一个egg和jinja2期望一个目录,而不是包含所有静态和html文件的zip / egg文件

看着谷歌,我发现了一个名为" - 旧又无法管理的选项"可以与python setup.py安装一起使用,并允许以旧方式(普通包和文件)而不是新方式(egg文件)安装项目。

无论如何在烧瓶项目中使用jinja2模板而不使用选项" - old-and-unmanageable" ??

安装包

完整错误:

[2014-11-02 10:25:35 -0200] [7464] [ERROR] Socket error processing request.
Traceback (most recent call last):
  File "/home/arthas/htpwd/lib/python3.4/site-packages/gunicorn/workers/sync.py", line 93, in handle
    self.handle_request(listener, req, client, addr)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/gunicorn/workers/sync.py", line 150, in handle_request
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/home/arthas/htpwd/lib/python3.4/site-packages/gunicorn/six.py", line 354, in reraise
    raise value
  File "/home/arthas/htpwd/lib/python3.4/site-packages/gunicorn/workers/sync.py", line 134, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/htpwd-0.2.0-py3.4.egg/htpwd/htmanager.py", line 77, in root
    return render_template('index.html', form=form)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/templating.py", line 127, in render_template
    return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "/home/arthas/htpwd/lib/python3.4/site-packages/jinja2/environment.py", line 830, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/jinja2/environment.py", line 791, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/home/arthas/htpwd/lib/python3.4/site-packages/jinja2/environment.py", line 765, in _load_template
    template = self.loader.load(self, name, globals)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/flask/templating.py", line 60, in get_source
    return loader.get_source(environment, local_name)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/jinja2/loaders.py", line 163, in get_source
    f = open_if_exists(filename)
  File "/home/arthas/htpwd/lib/python3.4/site-packages/jinja2/utils.py", line 150, in open_if_exists
    return open(filename, mode)
NotADirectoryError: [Errno 20] Not a directory: '/home/arthas/htpwd/lib/python3.4/site-packages/htpwd-0.2.0-py3.4.egg/htpwd/templates/index.html'

0 个答案:

没有答案