iT邦幫忙

0

line機器人python的module無法執行

參考https://stackoverflow.com/questions/49353905/no-module-named-future
用各種方式pip future了
還是No module named 'future'
https://ithelp.ithome.com.tw/upload/images/20200703/20126988zFf81uOgqd.png
這裡是按照官網那邊找的程式碼
求救!!!謝謝大大

#app.py
from flask import Flask, request, abort

from linebot import (
    LineBotApi, WebhookHandler
)
from linebot.exceptions import (
    InvalidSignatureError
)
from linebot.models import (
    MessageEvent, TextMessage, TextSendMessage,
)

app = Flask(__name__)

line_bot_api = LineBotApi('貼上你的line bot channel token')
handler = WebhookHandler('貼上你的line bot channel secret')


@app.route("/callback", methods=['POST'])
def callback():
    # get X-Line-Signature header value
    signature = request.headers['X-Line-Signature']

    # get request body as text
    body = request.get_data(as_text=True)
    app.logger.info("Request body: " + body)

    # handle webhook body
    try:
        handler.handle(body, signature)
    except InvalidSignatureError:
        abort(400)

    return 'OK'


@handler.add(MessageEvent, message=TextMessage)
def handle_message(event):
    line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(text=event.message.text))


if __name__ == "__main__":
    app.run()
看更多先前的討論...收起先前的討論...
lydia0231 iT邦新手 5 級 ‧ 2020-07-03 20:04:47 檢舉
我暫時找到解決方式了,從本地找到future複製丟進程式資料夾目錄裡......
你有想過原因嗎?
froce iT邦大師 1 級 ‧ 2020-07-04 20:45:56 檢舉
你用conda要conda install吧?
lydia0231 iT邦新手 5 級 ‧ 2020-07-11 00:12:48 檢舉
@froce 謝謝,你點醒了我,是conda的原因,然而我用conda安裝還是沒反應,把anconda全部刪掉,改用pip就可以了
lydia0231 iT邦新手 5 級 ‧ 2020-07-11 00:13:17 檢舉
@一級屠豬士 想了很久很久,終於想通了
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答