Transformers in requirements.txt but Error -> No module named 'transformers'

Hi guys,

I’ve added “Transformers” in the requirements.txt file, but I got a ModuleNotFoundError -> No module named 'transformers' when I’m trying to deploy in Streamlit share.

Not sure what I’m doing wrong here. Here’s the app if you wanted to have a glance:


Check the sidebar for an error message. We launch the app even if a pip failure occurs, so there’s probably a message that some driver was missing or something else to cause the requirements not to get installed properly.

1 Like

I see, thanks Randy!

So I’ve checked and removed the errors seen in the log file. No more ModuleNotFoundError -> No module named 'transformers' - great news! :slight_smile:

The app shows another issue, however, and the installation seems to keep going/never stops:

I pasted the log here:

I can’t seem to find any error here, except:

[manager] Error checking Streamlit healthz: Get "http://localhost:8501/healthz": read tcp> read: connection reset by peer

I’ll keep trying various things over the weekend! :slight_smile:


Quick heads-up @randyzwitch :slight_smile:

15 tries later, it’s still not working and the installation keeps looping it seems … :sweat_smile:
(Latest error log is here, as well as the repo)

I think I know where the issue is coming from yet not sure how to fix it.

When I try the same script in Google Colab, Colab downloads all the needed weights/models.

I believe we need a way to upload these models to Streamlit Sharing, yet not sure how to do it:

Maybe via an extra text file?


1 Like

Do you have a feeling for the cumulative size of the models? I’m wondering if you’re exceeding the VM size, and it’s caught in an unfortunate deploy cycle

1 Like

It relies on GPU PyTorch. To give you an idea of size, here’s the error I get in the free version of Heroku (capped at 500M):

Compiled slug size: 863.7M is too large (max is 500M).


Currently, we’re at 800MB for the limits

Thanks Randy.

So I’ve reduced size to 247MB (according to Heroku) by downloading CPU only wheels:

It works fine in Heroku yet still the same looping issue in Streamlit Sharing:thinking:

How did you solve this importing error? I’m getting the same in my local computer, I’ve reinstalled streamlit 3 times now :frowning: