2017-09-23 100 views
0

我的作用域是通過cron作業在雲中運行python腳本(它從網站中刪除文本並將其保存在csv文件中)。 爲此,我選擇了Heroku。在Heroku上運行Python Worker - 推送失敗

我被卡住了,因爲當我嘗試部署工作人員時,我得到推送拒絕。

這是我做的: 我把我的scrapit.py和Procfile('worker:node scrapit.py')放到一個目錄中。

再經過我創建Heroku上的應用程序,我從上面的目錄發送下列命令:

$ heroku login 
$ git init 
$ heroku git:remote -a app-name-on-heroku 
$ git add . 
$ git commit -am "nth time :(" 
$ git push heroku master 

我得到以下信息:

Counting objects: 41, done. Delta compression using up to 4 threads. Compressing objects: 100% (36/36), done. Writing objects: 100% (41/41), 12.97 KiB | 0 bytes/s, done. Total 41 (delta 6), 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 app-name-on-heroku. remote: To https://git.heroku.com/app-name-on-heroku.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to ' https://git.heroku.com/app-name-on-heroku.git '

我送這個錯誤後命令:

heroku buildpacks:set heroku/python 

,但仍是推被拒絕

+0

我需要一個requirements.txt嗎? – user3755529

回答

1

每個Heroku buildpack都指定一個bin/detect文件,讓平臺知道該buildpack是否可以與該應用程序一起使用。

python buildpack要求:requirements.txt,setup.pyPipfile要存在。
您需要創建(並正確配置)其中一個文件,以便能夠構建您的python應用程序。

+0

它工作。現在python腳本可以編寫.csv文件。 Heroku似乎運行了它,我期待從Heroku中獲取那些用Git獲取的文件,但是沒有任何東西可以顯示出來..我不知道如何獲得這些.csv文件,或者即使python腳本實際上將它們寫入Heroku – user3755529

+1

您可能想閱讀https://devcenter.heroku.com/articles/how-heroku-works#running-applications-on-dynos 每個heroku dyno都是一個容器。在磁盤上寫文件不會改變您的GIT存儲庫。如果您需要編寫文件並檢索它,則需要將其存儲在諸如Amazon S3的系統上,或者爲其設置自己的HTTP端點。 –