擅长:python、mysql、java
<p>添加一些可以遍历的调试语句:</p>
<pre><code>import sys
BARCODE_IMAGE_PATH = "/tmp/"
def create_barcode_image(product_barcode):
print >> sys.stderr, "product_barcode: %s" % product_barcode
path = BARCODE_IMAGE_PATH + product_barcode + '.png'
print >> sys.stderr, "path: %s" % path
img = barcode('ean13', product_barcode,
options=dict(includetext=True, height=0.4), margin=1)
print >> sys.stderr, "img data: %s" % img.tostring()
img.save(path, 'PNG')
print >> sys.stderr, "Saved to %s" % path
return path
</code></pre>
<p>那么在你的壳里:</p>
<pre><code>$ tail -F /var/log/httpd/error.log # or wherever you put it
</code></pre>
<p>您正在寻找:第一个:输出“<code>product_barcode: ...</code>”。希望这不是空白。如果是,那么问题就在其他地方,可能在您的服务器配置中。然后输出“<code>img data: ...</code>”。希望是png而不是空白。如果是空的,那么问题就在于您的ghostscript安装。</p>
<p>这是一种非常基本的调试方法,我觉得对于小项目来说,插入一些调试语句也很容易,而不是搞乱调试器,因为调试器很难正确设置。</p>