簡體   English   中英

應用與 buildpack 不兼容 - Heroku

[英]App not compatible with buildpack - Heroku

當我運行git push heroku master這是我得到的:

C:\Users\Emanuele-PC\Desktop\project-mm-beta>git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 505 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to project-mm-beta.
remote:
To https://git.heroku.com/project-mm-beta.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project-mm-beta.git'

我嘗試部署的代碼只是一個文件(這是一個測試,因為這是我第一次使用 Heroku),它是用 Python 編寫的。 我已經設置了 buildpack (python),但它仍然不起作用。 我該如何解決?

只有當應用程序在根目錄中有 Pipfile 或requirements.txt時,Heroku Python 支持才會應用於應用程序。

訪問文檔以獲取詳細說明。

我剛剛發現......這是一個非常愚蠢的問題。 確保 git repo 在項目根文件夾中初始化。 假設該項目是一個 Django 應用程序,並且由 Django 創建的項目文件夾是my-project ,則需要在my-project初始化 git repo 才能使 Heroku 工作......

添加pipfile和procfile,並提交它們,這為我解決了:)

您可以在此 heroku 示例中看到我所說的文件:鏈接

github上的heroku buildpack:鏈接

嘗試添加一個名為 requirements.txt 的文件並輸入您需要的任何內容,例如 django

步驟 1)首先設置 buildpack(編程語言)

例如: heroku buildpacks:set heroku/nodejs

在此處查看更多信息: https : //devcenter.heroku.com/articles/buildpacks

如果問題仍然存在,請執行下一步

Step 2) git init 和當前使用的目錄不同,所以還是拋出這個錯誤“App not compatible with buildpack:”

例如: git init命令用於在以下位置執行:- C:/sample_folder/

但是modules 和 package.json位於嵌套的子文件夾下:-

C:/sample_folder/nodejs_app/package.json

因此,相應地移動文件,使所有文件都存在於同一文件夾下,然后運行

git push heroku master

--快樂編碼!

我收到此錯誤是因為我正在對不同的分支進行更改。 所以我正在處理一個功能分支,然后運行git push heroku master 我的更改尚未合並到我的主分支中,因此出現錯誤。 一旦我將 Procfile 合並到 master,我就能夠將更改推送到 heroku。

我遇到了同樣的錯誤,因為我沒有提交文件,請確保運行命令git add . 然后在更改任何文件后git commit -m'message' ,然后您可以run git push heroku master並正確添加requirements.txtProcfile

你可以嘗試這樣做:

  1. pip3 freeze > requirements.txt
  2. heroku buildpacks:set heroku/python
  3. git add .; git commit -m "add requirements.txt"; git push heroku master

注意:確保您位於 Python 項目的根目錄中 :)

最后確保您沒有忽略 .gitignore 中的requirements.txt ,那是我的問題。

您可以通過此方法為python指定buildpack

命令行安裝

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python.git

檢查您是否執行了以下步驟:

  1. 激活您的虛擬環境。

  2. 在命令提示符下運行:
    pip freeze>requirements.txt

  3. 在您的主應用程序目錄中添加Procfile (與manage.py所在的位置相同);
    在 Procfile 中,您應該插入:
    web: gunicorn your_app_name.wsgi

第一個文件: requirements.txt

包含以下內容: gunicorn==19.7.1pip freeze > requirements.txt任何結果。

第二個文件: Procfile

包含以下內容: web: gunicorn app:app或可能為空白。 請注意,本示例中的app:app是對您的 Python 文件名的引用。 這意味着每次聲明 Web 進程並啟動gunicorn app:app ,還要運行命令gunicorn app:app來啟動您的 Web 服務器。

然后git add . git commit -m "added Procfile and requirements.txt"

然后運行git push heroku masterlocal master分支推送到heroku remote

好吧,當我第一次創建Heroku應用程序時,我也遇到了同樣的情況。 只需添加requirements.txt 它會正常工作。

我遇到過同樣的問題。 只需確保您在 django 項目根目錄中初始化了 git repo。 這樣,您的 .git 文件夾、.gitignore 文件、manage.py、requirements.txt 等都在同一層級。

-> 確保您的 requirements.txt 和 Procfile 位於根文件夾中。

-> 如果您不在 master 分支中,請運行以下命令。

git checkout -b master
git add .
git commit -m "your commit message"
git push -u origin master
git push heroku master

我剛剛從連接到 Heroku 應用程序的 GitHub 存儲庫中刪除了 README.md,這對我有用!

檢查您是否編寫了正確拼寫的 Procfile 和 requirements.txt,因為它們區分大小寫,在我的情況下,將 procfile 更改為 Procfile 后,它開始正常工作。

運行此命令:

heroku buildpacks:set heroku/python

你也可以參考這個文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM