Heroku + gunicorn 不工作(bash:gunicorn:找不到命令)
Heroku + gunicorn not working (bash: gunicorn: command not found )
我成功安装了 gunicorn:
remote: -----> Removing .DS_Store files
remote: -----> Python app detected
remote: -----> Installing dependencies with pip
remote: Collecting gunicorn==19.0.0 (from -r requirements.txt (line 1))
remote: Downloading gunicorn-19.0.0.tar.gz (382kB)
remote: Installing collected packages: gunicorn
remote: Running setup.py install for gunicorn
remote: Successfully installed gunicorn-19.0.0
我的个人资料:
web: gunicorn myapp:app --log-file=-
但是应用程序在部署时崩溃:
bash: gunicorn: command not found
我尝试添加 heroku python buildpack,但没有成功。如果我回滚到之前的提交(其中 requirements.txt
和 Procile
均未更改),它会起作用:
heroku/web.1: Starting process with command `gunicorn myapp:app --log-file=-`
app/web.1: 2015-10-08 17:04:18 [3] [INFO] Listening at: http://0.0.0.0:51854 (3)
确保 gunicorn
在您的 requirements.txt
中
远程卸载所有要求并重新安装后,问题似乎自行解决。
我缺少 heroku/python buildpack
所以我去了仪表板并:
Settings -> Add buildpack -> heroku/python
如果项目根目录中同时有 requirements.txt 和 Pipfile,那么我建议删除 Pipfile 并将所有要求列在 requirements.txt 文件(包括 gunicorn)中。
然后将显示:"Installing requirements from pip",并且将安装 requirements.txt 中列出的所有要求。
检查 gunicorn
在 requirements.txt
之后 运行:
pip install -r requirements.txt
我的输出包含几个 Requirement already satisfied: ...
但未安装 gunicorn
:
Collecting gunicorn (from -r requirements.txt (line 2))
Using cached ...
Installing collected packages: gunicorn
Successfully installed gunicorn-19.9.0
就我而言,我在 'Procfile' 内部遇到问题。
我在 gunicorn
之后删除了 :
。
web: gunicorn: app:app -> web: gunicorn app:app
Heroku 的 Python 文档似乎已经过时了......显然他们现在更喜欢 Pipfile 而不是 requirements.txt
,但幸运的是你可以很容易地生成一个 pipenv
.
试试这个:
$ pip3 install --user pipenv
安装 pipenv
$ pipenv install gunicorn
将 gunicorn 添加到 pipfile
$ pipenv shell
激活
我遇到了完全相同的错误,这对我有用!
就我而言,存在冲突,因为我在同一目录/项目中同时拥有 Pipfile
、Pipfile.lock
和 requirements.txt
文件。
Heroku 没有从 requirements.txt
安装任何东西,因此与这里的每个人都出现相同的 gunicorn 错误。
您还需要确保 运行 您的 git push heroku master
要求是从 requirements.txt 安装的,而不是从 pipfile 或 pipfile.lock 安装的。因此,如果您使用 requirements.txt
安装依赖项,请确保从 cd 目录中删除这些文件
在您的虚拟环境中安装gunicorn
pip install gunicorn
然后更新您的 requirements.txt
文件
pip freeze > requirements.txt
在 requirements.txt 中添加 gunicorn 解决了我的问题。
就我而言,尽管 gunicorn 在 requirements.txt 中,但由于存在 Pipfile,gunicorn 并未安装。我从我的 github 存储库中删除了 Pipfile 并成功重新部署。
以下简短教程也有助于确保我已正确配置 runtime.txt、wsgi.py 和 Procfile 的要点。
https://www.geeksforgeeks.org/deploy-python-flask-app-on-heroku/
在我的例子中,这是因为 Pipfile
gunicorn
在 dev-packages
之下。将其作为常规软件包安装有效。只有 Pipfile
。不需要 requirements.txt
。
我遇到了同样的问题,但是在添加之后
gunicorn===<latest-version>
到 requirements.txt 文件已修复。
我不知道它为什么起作用,但我遇到了同样的问题,在阅读了其他建议后,我最终删除了我的 requirements.txt 文件(即使它有 gunicorn)和 运行 pip freeze > requirements.txt
再次解决了问题。
就我而言,我的 Heroku 应用缺少 python buildpack,因此 没有安装任何包 。
我通过添加一个解决了这个问题:Settings
> Buildpacks
> Add buildpack
> python
当 gunicorn 安装不正确时会发生...
并且为了再次安装,安装程序只能在 requirments.txt
发生变化时安装文件
所以请按照以下步骤操作:-
首先,在 requirments.txt 中安装一个空的或只有一个东西
将使安装程序安装一些东西,因为 requirments.txt 中有变化,并在 git inti 之后遵循完整的完整 setps ....等等
之后用完整的 requirments.txt 文件重复所有步骤
它肯定会起作用....
我的就是这样解决的..
谢谢
我成功安装了 gunicorn:
remote: -----> Removing .DS_Store files
remote: -----> Python app detected
remote: -----> Installing dependencies with pip
remote: Collecting gunicorn==19.0.0 (from -r requirements.txt (line 1))
remote: Downloading gunicorn-19.0.0.tar.gz (382kB)
remote: Installing collected packages: gunicorn
remote: Running setup.py install for gunicorn
remote: Successfully installed gunicorn-19.0.0
我的个人资料:
web: gunicorn myapp:app --log-file=-
但是应用程序在部署时崩溃:
bash: gunicorn: command not found
我尝试添加 heroku python buildpack,但没有成功。如果我回滚到之前的提交(其中 requirements.txt
和 Procile
均未更改),它会起作用:
heroku/web.1: Starting process with command `gunicorn myapp:app --log-file=-`
app/web.1: 2015-10-08 17:04:18 [3] [INFO] Listening at: http://0.0.0.0:51854 (3)
确保 gunicorn
在您的 requirements.txt
远程卸载所有要求并重新安装后,问题似乎自行解决。
我缺少 heroku/python buildpack 所以我去了仪表板并:
Settings -> Add buildpack -> heroku/python
如果项目根目录中同时有 requirements.txt 和 Pipfile,那么我建议删除 Pipfile 并将所有要求列在 requirements.txt 文件(包括 gunicorn)中。
然后将显示:"Installing requirements from pip",并且将安装 requirements.txt 中列出的所有要求。
检查 gunicorn
在 requirements.txt
之后 运行:
pip install -r requirements.txt
我的输出包含几个 Requirement already satisfied: ...
但未安装 gunicorn
:
Collecting gunicorn (from -r requirements.txt (line 2))
Using cached ...
Installing collected packages: gunicorn
Successfully installed gunicorn-19.9.0
就我而言,我在 'Procfile' 内部遇到问题。
我在 gunicorn
之后删除了 :
。
web: gunicorn: app:app -> web: gunicorn app:app
Heroku 的 Python 文档似乎已经过时了......显然他们现在更喜欢 Pipfile 而不是 requirements.txt
,但幸运的是你可以很容易地生成一个 pipenv
.
试试这个:
$ pip3 install --user pipenv
安装 pipenv
$ pipenv install gunicorn
将 gunicorn 添加到 pipfile
$ pipenv shell
激活
我遇到了完全相同的错误,这对我有用!
就我而言,存在冲突,因为我在同一目录/项目中同时拥有 Pipfile
、Pipfile.lock
和 requirements.txt
文件。
Heroku 没有从 requirements.txt
安装任何东西,因此与这里的每个人都出现相同的 gunicorn 错误。
您还需要确保 运行 您的 git push heroku master
要求是从 requirements.txt 安装的,而不是从 pipfile 或 pipfile.lock 安装的。因此,如果您使用 requirements.txt
在您的虚拟环境中安装gunicorn
pip install gunicorn
然后更新您的 requirements.txt
文件
pip freeze > requirements.txt
在 requirements.txt 中添加 gunicorn 解决了我的问题。
就我而言,尽管 gunicorn 在 requirements.txt 中,但由于存在 Pipfile,gunicorn 并未安装。我从我的 github 存储库中删除了 Pipfile 并成功重新部署。
以下简短教程也有助于确保我已正确配置 runtime.txt、wsgi.py 和 Procfile 的要点。
https://www.geeksforgeeks.org/deploy-python-flask-app-on-heroku/
在我的例子中,这是因为 Pipfile
gunicorn
在 dev-packages
之下。将其作为常规软件包安装有效。只有 Pipfile
。不需要 requirements.txt
。
我遇到了同样的问题,但是在添加之后
gunicorn===<latest-version>
到 requirements.txt 文件已修复。
我不知道它为什么起作用,但我遇到了同样的问题,在阅读了其他建议后,我最终删除了我的 requirements.txt 文件(即使它有 gunicorn)和 运行 pip freeze > requirements.txt
再次解决了问题。
就我而言,我的 Heroku 应用缺少 python buildpack,因此 没有安装任何包 。
我通过添加一个解决了这个问题:Settings
> Buildpacks
> Add buildpack
> python
当 gunicorn 安装不正确时会发生... 并且为了再次安装,安装程序只能在 requirments.txt
发生变化时安装文件所以请按照以下步骤操作:-
首先,在 requirments.txt 中安装一个空的或只有一个东西 将使安装程序安装一些东西,因为 requirments.txt 中有变化,并在 git inti 之后遵循完整的完整 setps ....等等
之后用完整的 requirments.txt 文件重复所有步骤 它肯定会起作用....
我的就是这样解决的.. 谢谢