1

main.py

from flask import Flask
import pickle
import pandas as pd

app = Flask(__name__)

with open('C:\\Users\\captain\\Desktop\\flask\\my-project\\movies.pkl', 'rb') as f:
    Movies = pickle.load(f)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

The code shown above is giving this error (shown in image) when I run "flask --app main run" this statement :

But while running the main.py in the console it runs perfectly and I was able to print the Movies data using the print statement.

the data type of Movies = <class 'pandas.core.frame.DataFrame'>

I was just expecting that the Flask app would run fine without any errors.

Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24
Captain
  • 11
  • 2
  • 1
    Please read [Why should I not upload images of code/data/errors?](https://meta.stackoverflow.com/q/285551/354577) Instead, format code as a [code block]. The easiest way to do this is to paste the code as text directly into your question, then select it and click the code block button. – ChrisGPT was on strike Apr 23 '23 at 16:10
  • this looks like a duplicate of https://stackoverflow.com/a/75953280/4212158 – crypdick Apr 25 '23 at 00:08

1 Answers1

1

This issue is similar with this thread, although you have it with pickle rather than metaflow

ModuleNotFoundError: No module named 'pandas.core.indexes.numeric' using Metaflow

And the solution is the same:

pip install "pandas<2.0.0"

Tested on my computer (Ubuntu 22.04, Python 3.10.6) and pickle works again.

Patrick Wu
  • 98
  • 1
  • 7