【问题标题】:How to run gunicorn as python3如何以 python3 运行 gunicorn
【发布时间】:2022-11-10 09:32:04
【问题描述】:

当我运行 gunicorn 时,总是执行 python2。

gunicorn -c gunicorn_config.py app:app

...

ps -ef | grep gunicorn

user    34877      1  0 16:31 ?        00:00:00 /usr/bin/python2 /usr/bin/gunicorn -c gunicorn_config.py app:app
user    34883  34877  0 16:31 ?        00:00:00 /usr/bin/python2 /usr/bin/gunicorn -c gunicorn_config.py app:app
user    34884  34877  0 16:31 ?        00:00:00 /usr/bin/python2 /usr/bin/gunicorn -c gunicorn_config.py app:app
...

(如果你想检查我的环境,请关注这个 repo :https://github.com/be-hase/ghe-line-notify

如何将 gunicorn 作为 python 3 运行?

我认为这是将 gunicorn 作为 python2 运行引起的错误。

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 379: ordinal not in range(128)

【问题讨论】:

    标签: python python-3.x gunicorn python-2.x


    【解决方案1】:

    这花了太多时间,但太简单了。 我可以使用以下命令检查 gunicorn 的位置。 (已经安装了python3)

    $ whereis gunicorn
    gunicorn: /usr/bin/gunicorn /usr/local/bin/gunicorn
    

    然后,我就这样跑。

    $ /usr/local/bin/gunicorn -c gunicorn_config.py app:app
    

    然后,我可以看到

    user    39677  39672  3 16:51 ?        00:00:00 /usr/bin/python3 /usr/local/bin/gunicorn -c gunicorn_config.py app:app
    user    39678  39672  3 16:51 ?        00:00:00 /usr/bin/python3 /usr/local/bin/gunicorn -c gunicorn_config.py app:app
    ...
    

    此外,我将 Python 别名更改为 Python 3 路径并尝试了它,但它没有解决它,但我不知道为什么。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-11
      • 2017-12-08
      • 2016-06-03
      • 2020-07-20
      • 2022-01-19
      • 2012-06-20
      • 2017-12-02
      相关资源
      最近更新 更多