Local ModuleNotFoundError

I’m getting an module not found error when running my app locally. I’m trying to import the nba-api module. I don’t get an error when running a script locally but whenever i try to run ‘streamlit run Home.py’ locally i get a module not found error.

2023-11-11 22:41:52.677 Uncaught app exception
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 534, in _run_script
exec(code, module.dict)
File “/Users/parth/coding_projects/sports/Home.py”, line 3, in
from data.nba.api import get_player_list
File “/Users/parth/coding_projects/sports/data/nba/api.py”, line 1, in
from nba_api.stats.static import players
ModuleNotFoundError: No module named ‘nba_api’.


import streamlit as st

from data.nba.api import get_player_list

st.title("NBA Player Stats Explorer")
player = st.selectbox("Select Player", get_player_list())

Hey @codr,

Have you installed the nba-api package?

1 Like

Hi @codr

In addition to checking if the package is installed (including it in the requirements.txt file) you can also try including the import statements in all files of the app (the main app and also the py file where the function resides).

Hope this helps