前提・実現したいこと
はじめまして。
PythonでTwitterのBot
(特定のアカウントのツイートを取得し、深夜だった場合リプライを送る)を作成し、
Herokuで運用しようとしていたのですが、
デプロイがうまくいかないので質問させていただきます。
発生している問題・エラーメッセージ
デプロイがうまくいきません。
Pythonがサポート外だといわれるのですが、
python-3.6.5を導入しており原因が分かりません。
おそらくあっちこっちから継ぎ接ぎで作ったのが原因だと思うのですが…
以下エラーメッセージです。
===================================
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.5 (you are using python-3.6.5, which is unsupported).
remote: ! We recommend upgrading by specifying the latest version (python-3.6.5).
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.6.5
remote: ! Requested runtime (python-3.6.5) is not available for this stack (heroku-16).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to morning-bastion-45920.
remote:
To https://git.heroku.com/morning-bastion-45920.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/morning-bastion-45920.git'
###ソースコード
Procfile
web: python index.py
index.py
python
1#coding:utf-8 2import os 3from bottle import route, run 4 5@route("/") 6def hello_world(): 7 return "hello world" 8 9run(host="0.0.0.0", port=int(os.environ.get("PORT",5000)))
tweet.py
python
1#coding; utf-8 2 3from requests_oauthlib import OAuth1Session 4import json 5from urllib import request 6 7username = "~~~~~~~~~~"(これは仮です) 8 9keys = { 10 "CK":'XXXXXXXXXXXXXXXXX', 11 "CS":'XXXXXXXXXXXXXXXXXXXXXX', 12 "AT":'XXXXXXXXXXXXXXXXXXX', 13 "AS":'XXXXXXXXXXXXXX', 14 }(直接置くのは無作法ではありますが自分以外使わないし当座の処置として…実際には入力されています。) 15 16sess = OAuth1Session(keys["CK"], keys["CS"], keys["AT"], keys["AS"]) 17 18url = "https://api.twitter.com/1.1/statuses/user_timeline.json" 19params = {"screen_name":username, #TwitterIDを指定 20 "count":1, 21 } 22 23req = sess.get(url, params=params) 24timeline = json.loads(req.text) 25 26for tweet in timeline: 27 tweetsitanitizi = tweet["created_at"] 28 tweetsitazikan = tweetsitanitizi[11:13] 29 zikan= int(tweetsitazikan) 30 31 32tweetnaiyou = "@"+tweet["user"]["screen_name"]+tweet["user"]["name"]+"さん、早く寝ましょう。" 33 34if zikan > 15 and zikan < 21: 35 url2 = "https://api.twitter.com/1.1/statuses/update.json" 36 params2 = {"status":tweetnaiyou, 37 "in_reply_to_status_id":tweet["id_str"], 38 } 39 40 req = sess.post(url2, params = params2) 41
runtime.text
python-3.6.5
requirements.text
jsonlib-python3==1.6.1
oauthlib==2.0.6
requests-oauthlib==0.8.0
urllib3==1.21.1
requests==2.18.4
bottle==0.12.13
回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。