添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello everyone,

I am very new to streamlit and trying to deploy my first app.
I have used a model to predict board game ratings, which worked fine locally but when I deployed it I got “ ModuleNotFoundError: No module named 'lightgbm ” error.

When I edit it on codespaces, the app seems to run without any problems in the simple browser, as well.

I have checked some of the suggestions I could find online, such as updating requirements.txt to include lightgbm,

Link to my app is : https://bgilkdeneme.streamlit.app/
and link to my repo is: GitHub - SeckinD/Streamlit

any help will be much appreciated.

Hi @Seckind

The ModuleNotFoundError typically tells us that a dependent library is missing and should be installed.

As you had mentioned that you had added lightgbm to requirements.txt, this should resolve the issue. If not, it may be resolved by rebooting the app.

I’ve created a simple lightgbm use case here:

import numpy as np import lightgbm as lgb from sklearn.model_selection import train_test_split from sklearn.metrics import r2_score from sklearn import metrics st.title('🎈 LightGBM') # Load data df = pd.read_csv('https://raw.githubusercontent.com/dataprofessor/data/master/delaney_solubility_with_descriptors.csv') # Separate data as X, y X = df.iloc[:,:-1] y = df.iloc[:,-1] # Data split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.8, random_state=42) # Model training model = lgb.LGBMRegressor(learning_rate=0.09, max_depth=-5, random_state=42, force_col_wise=True) model.fit(X_train, y_train) # Model performance y_train_pred = model.predict(X_train) y_test_pred = model.predict(X_test) st.write('Train *R*\u00b2: {:.3f}'.format(r2_score(y_train, y_train_pred))) st.write('Test *R*\u00b2: {:.3f}'.format(r2_score(y_test, y_test_pred)))

This was deployed successfully on Community Cloud and the demo app is available at:

Thank you @dataprofessor for taking the time to build the demo app.
Indeed, rebooting the app seems to have solved the problem (who could have thought? :man_facepalming: )
Really appreciate the input!

Thanks for stopping by! We use cookies to help us understand how you interact with our website. By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy .

Strictly necessary cookies

These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.

Performance cookies

These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.

Functional cookies

These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.

Targeting cookies

These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.

Reject all Accept all