值错误:使用pelican content命令在Windows上生成我的站点时嵌入的空字节

时间:2015-12-23 11:01:19

标签: windows python-3.x pelican

我想用Pelican来生成我的博客网站。我在{7}的指导下在Windows 7上通过pip安装python 3和Pelican。我在D:/blog下创建了一个目录来存储我的站点文件。然后在test.md下创建一个名为D:/blog/content的文件,test.md的内容与快速入门指南相同。当进入步骤docs quickstart时,我收到错误 在gitbash中如下:

Generate your site

那么,为什么会发生这种情况以及如何解决它?感谢。

更新,使用pelican content --debug命令获取回溯,密钥追溯在此处:

enter image description here

1 个答案:

答案 0 :(得分:1)

根据bug report,此问题是由于locale设置不正确造成的。

执行fllowing代码,如果发生错误,则存在locale设置问题。

import locale, time
locale.setlocale(locale.LC_ALL, 'ko')
time.strftime('%a')

<强>解决方案:

路径utils.py下的错误文件为..\Lib\site-packages\pelican\utils.py。在strftime function中添加以下代码以解决问题。

locale.setlocale(locale.LC_ALL, 'en')

添加(例如)后:

def strftime(date, date_format):
    '''
    Replacement for built-in strftime
    ...(Omit some words)
    replacing formatted output back.
    '''
    locale.setlocale(locale.LC_ALL, 'en')

    def strip_zeros(x):
        return x.lstrip('0') or '0'
    c89_directives = 'aAbBcdfHIjmMpSUwWxXyYzZ%'

您还可以在this blog post

中看到中文版