【问题标题】:Correct Directory for Procfile for HerokuHeroku Procfile 的正确目录
【发布时间】:2016-03-06 17:32:21
【问题描述】:

我正在尝试将基本的 Python 博客/网站迁移到 Heroku 以将其部署到 Internet。我部分完成了该过程,并且无法正确获取 Procfile。我正在按照here for Heroku 显示的说明进行操作。

“Mysite”是我网站的顶级目录。按照说明,我已将 virtualenv 放入其中。

我不确定 Procfile 需要去哪里 - 这是我遇到的错误:

C:\Users\andre\mysite>virtualenv venv
Using base prefix 'c:\\users\\andre\\appdata\\local\\programs\\python\\python35-32'
New python executable in venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.

C:\Users\andre\mysite>venv\Scripts\activate
(venv) C:\Users\andre\mysite>pip freeze > requirements.txt
You are using pip version 7.1.2, however version 8.1.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(venv) C:\Users\andre\mysite>pip install -r requirements.txt
Requirement already satisfied (use --upgrade to upgrade): wheel==0.24.0 in c:\users\andre\mysite\venv\lib\site-packages (from -r requirements.txt (line 1))
You are using pip version 7.1.2, however version 8.1.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(venv) C:\Users\andre\mysite>heroku local web
ERROR: open Procfile: The system cannot find the file specified.

我尝试将 Procfile 放置在几个不同的位置,但没有任何运气可以消除错误。

我正在使用的 Procfile 有以下内容:

web: gunicorn mysite.wsgi --log-file -

文件目录如下:

andre/
    -Documents/
    -Desktop/
    -AppData/
        -Local/
             -heroku/
    -mysite/
        -blog/
        -mysite/
        -venv/
        -db.sqlite3
        -manage.py
        -Procfile
        -requirements.txt

关于我在这里可能做错的任何建议?谢谢你。

【问题讨论】:

    标签: python django heroku


    【解决方案1】:

    将其上移一个目录到存储库的根目录,并删除 .txt 扩展名。来自the documentation

    Procfile 是一个名为 Procfile 的文件。它应该准确地命名为Procfile,而不是其他任何东西。例如,Procfile.txt 无效。该文件应该是一个简单的文本文件。

    该文件必须放在应用程序的根目录中。如果放在子目录中,它将不起作用。

    本文档适用于 Heroku 支持的所有语言。当文档说“应用程序的根目录”时,它指的是根目录,而不是 Django 应用程序。

    【讨论】:

    • 谢谢克里斯。我尝试将 Procfile 在目录中向上移动,但这没有帮助 - 导致了同样的错误。我已经修改以显示我的目录的更多深度,这可能会带来更多的亮点。基本上,“andre”文件夹是我电脑的通用目录。另外,我从 Procfile 中删除了“.txt”,但这也无济于事。
    • @AME,您的 Procfile 似乎引用了一个不存在的文件:mysite.wsgi。你有 WSGI 文件吗?
    • 没错,克里斯,我曾假设配置/定位 WSGI 文件会在此过程的后期进行,尽管我可能弄错了。你认为这是问题吗?我认为问题在于 Procfile 没有被定位和读取。我在目录 (@andre/mysite/mysite/wsgi.py) 中确实有一个 WSGI.py 文件。东西应该搬到那里吗?再次感谢。
    • @AME,我认为 WSGI 文件不需要在根目录下,Procfile 当然不应该被移动。尝试编辑Procfile 并将mysite.wsgi 替换为path/to/your/real/WSGI.py
    • 知道了 - 不幸的是仍然有同样的问题。还有一个想法——我的 requirements.txt 文件可能不正确吗?它唯一的内容是“wheel==0.24.0”——这看起来有问题吗?我还尝试按照此处文本中列出的建议将 Procfile 文本切换为“web: python manage.py runserver 0.0.0.0:$PORT”,但这也没有效果:devcenter.heroku.com/articles/deploying-python
    猜你喜欢
    • 1970-01-01
    • 2019-10-30
    • 1970-01-01
    • 2018-01-09
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    • 2014-11-14
    • 2016-12-15
    相关资源
    最近更新 更多