【问题标题】:Running gunicorn on Ubuntu in a conda environment在 conda 环境中在 Ubuntu 上运行 gunicorn
【发布时间】:2017-05-05 16:21:06
【问题描述】:

我正在尝试在运行 Ubuntu 的 EC2 实例上部署 Flask 应用程序。我已经设置了 WSGI 文件,但是在运行 gunicorn 时遇到了一些问题。起初,我用sudo apt-get install gunicorn 安装了gunicorn。但是,它使用错误版本的 python 运行,并且它为我的 Flask 应用程序使用的每个模块引发了导入错误。我确定这是因为我使用 conda 作为环境管理器,并且因为使用apt-get 安装将 gunicorn 置于权限虚拟环境之外。所以,我卸载了 gunicorn (sudo apt-get purge gunicorn) 并通过 conda (conda install gunicorn) 重新安装。现在,当我运行 gunicorn (gunicorn --bind 0.0.0.0:8000 wsgi:app) 时,我没有得到 50 行的回溯。但是,我确实收到以下错误:-bash: /usr/bin/gunicorn: No such file or directory。我尝试卸载 gunicorn 并使用 pip 重新安装,但仍然出现相同的错误。我已经尝试在 Google 和 StackOverflow 上搜索解决方案,但我发现我应该在虚拟环境中安装 gunicorn 来克服这个错误(我相信,我已经在这样做了)。我猜这个问题很容易解决,而且这个问题与我的无能有关,而不是 conda 或其他东西。任何建议将不胜感激。谢谢。

【问题讨论】:

    标签: python ubuntu gunicorn conda


    【解决方案1】:

    所以,我是对的 - 问题完全与我自己的无能有关。不过,我不会删除这个问题,而是自己回答并将其留在这里,以防任何未来的新手开发人员遇到同样的问题。事实证明,问题在于我在错误的目录中运行gunicorn --bind 0.0.0.0:8000 wsgi:app。在我cd 进入包含wsgi.py 的目录后,gunicorn 工作得很好。要点:gunicorn 必须在包含 wsgi.py 的目录中运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-21
      • 2020-10-01
      • 2014-08-12
      • 2019-06-06
      • 2015-08-26
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      相关资源
      最近更新 更多