kyleskom / NBA-Machine-Learning-Sports-Betting

NBA sports betting using machine learning
1.17k stars 430 forks source link

Flask: "ModuleNotFoundError: No module named 'pandas'" #125

Closed JimCollinsDC closed 1 year ago

JimCollinsDC commented 1 year ago

When I try to run the Flask version (flask --debug run) I get this error: Traceback (most recent call last): File "C:\Projects\NBA-Machine-Learning-Sports-Betting\main.py", line 3, in import pandas as pd ModuleNotFoundError: No module named 'pandas' Yes, pandas is installed. I'm running this in a venv if that helps. If i run the code normally ( python main.py -xgb -odds=fanduel ) it works fine.

mendez97cr commented 1 year ago

Maybe you have more than one version of Python installed and the pandas files got installed in the wrong one.

On Sun, Feb 26, 2023, 1:50 PM Jim Collins @.***> wrote:

When I try to run the Flask version (flask --debug run) I get this error: Traceback (most recent call last): File "C:\Projects\NBA-Machine-Learning-Sports-Betting\main.py", line 3, in import pandas as pd ModuleNotFoundError: No module named 'pandas' Yes, pandas is installed. I'm running this in a venv if that helps. If i run the code normally ( python main.py -xgb -odds=fanduel ) it works fine.

— Reply to this email directly, view it on GitHub https://github.com/kyleskom/NBA-Machine-Learning-Sports-Betting/issues/125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXCGXW4MOX64LKJG6CIVDS3WZO6ZXANCNFSM6AAAAAAVIVMS4Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

JimCollinsDC commented 1 year ago

Again, I'm using venv. Also: "If i run the code normally ( python main.py -xgb -odds=fanduel ) it works fine."

JimCollinsDC commented 1 year ago

You pointed me in the right direction, kinda. subprocess doesn't know/care about your virtual environment, it uses the python on the path. Solution? change "cmd = ["python", "main.py", "-xgb", f"-odds={sportsbook}"] on line 27 to to cmd = ["../env/scripts/python", "main.py", "-xgb", f"-odds={sportsbook}"] Voilà: image

kyleskom commented 1 year ago

Awesome!