flingjie
V2EX  ›  Django

django 运行正常, gunicorn 运行报'ascii' codec can't encode…错误

  •  1
     
  •   flingjie ·
    flingjie · Jan 5, 2016 · 4621 views
    This topic created in 3824 days ago, the information mentioned may be changed or developed.

    定位到是 gunicorn 的编码问题, 经查找可以为 gunicorn 添加环境变量,在 /etc/supervisor/supervisord.conf 添加:

    environment=LANG=zh_CN.UTF-8,LC_ALL=zh_CN.UTF-8

    然后需要重启 supervisord, 搞定,下班

    2 replies    2016-01-06 10:39:44 +08:00
    latyas
        1
    latyas  
       Jan 6, 2016
    是不是 print 了中文 23333
    flingjie
        2
    flingjie  
    OP
       Jan 6, 2016
    @latyas 哈哈, 不是啊, 是数据库中有中文的内容
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   922 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:11 · PVG 04:11 · LAX 13:11 · JFK 16:11
    ♥ Do have faith in what you're doing.