在 conda 环境中 运行 Ubuntu 上的 gunicorn

Running gunicorn on Ubuntu in a conda environment

我正在尝试在 EC2 实例 运行ning Ubuntu 上部署 Flask 应用程序。我已经设置了我的 WSGI 文件,但是我遇到了一些问题 运行ning 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 和 Whosebug 上搜索解决方案,但我发现的只是我应该在虚拟环境中安装 gunicorn 以克服此错误(我相信我已经在做)。我猜想有一个简单的解决方法,这个问题与我的无能有关,而不是 conda 或其他东西。任何建议将不胜感激。谢谢。

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

的目录中的 运行