1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Vercel Deployment Issue with Python 3.12 Compatibility

Discussão em 'Python' iniciado por Stack, Outubro 6, 2024 às 00:52.

  1. Stack

    Stack Membro Participativo

    I'm trying to deploy my Flask app on Vercel, but I'm facing an issue where Vercel uses Python 3.12 instead of my preferred Python 3.10. My app runs perfectly fine locally with Python 3.10 in a virtual environment, but the deployment fails due to incompatible dependencies.

    I've created a runtime.txt file to specify Python 3.10, but it seems to be ignored, and I also ran pip check in my virtual environment, which indicates no broken requirements.

    When I run the deployment command (vercel --prod), I get this annoying error message:

    (.venv) PS C:\Users\morad\PycharmProjects\SmartBot\MyBot> vercel --prod
    Vercel CLI 37.6.1
    Inspect: https://vercel.com/moradeyo-davids-projects/nudge/BLUUsc3BgM4KoJMLPRieuDYkyyFZ [2s]
    ✅ Production: https://nudge-cet4gbp55-moradeyo-davids-projects.vercel.app [2s]
    Error: Command failed: pip3.12 install --disable-pip-version-check --target . --upgrade -r /vercel/path1/requirements.txt
    Traceback (most recent call last):
    File "/python312/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
    ^^^^^^^^^^^^^^^
    File "/python312/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
    return func(self, options, args)
    ^^^^^^^^^^^^^^^^^^^^^^^^^


    Below is the code in my app.py file:

    from flask import Flask, render_template, request, jsonify
    import requests

    RASA_API_URL = 'http://localhost:5005/webhooks/rest/webhook'
    app = Flask(__name__)

    @app.route('/')
    def index():
    return render_template('index.html')

    @app.route('/webhook', methods=['POST'])
    def webhook():
    user_message = request.json['message']
    print("User Message:", user_message)

    #Send user message to Rasa and get bot's response.
    rasa_response = requests.post(RASA_API_URL, json={'message': user_message})
    rasa_response_json = rasa_response.json()

    print("Rasa Response:", rasa_response_json)

    bot_response = rasa_response_json[0]['text'] if rasa_response_json else "Sorry, I didn\'t understand that."

    return jsonify({'response': bot_response})

    if __name__ == "__main__":
    app.run()

    Continue reading...

Compartilhe esta Página