ModuleNotFoundError despite simple requirements.txt present

Hi,

I have the following error when I deploy my app:

from pyairtable import Table
ModuleNotFoundError: No module named 'pyairtable'

I have a requirements.txt file at the root of my GitHub repository with only one line: pyairtable==1.1.0.

Did I miss anything?

Thanks for any help you can provide.

Hi @a455bcd9, and welcome to the Streamlit community! :balloon::raised_hands:

A few things you may try:

  • unpin the pyairtable version
  • check spellings and capitalisation
  • clear the cache
  • reboot the app

Hopefully one of these should fix it

Let us know how you go :slight_smile:

Best,
Charly

Hi @Charly_Wargnier ,

I tried all of that and still have the exact same problem, unfortunately.

My requirements.txt now only contains (no version specifier):

pyairtable

My python file contains at the top: from pyairtable import Table

I deleted the app and then re-created it.

What should I do?

Thanks for your help.

Best,

Antoine

Please give us a link to your public github repo.

Hi,

My repo was private. I create a public one with only requirements.txt and a simple python file (with the first lines of my original file that doesn’t work). Nothing else. I didn’t even configure Streamlit in this repo. And now… it works: GitHub - a455bcd9/streamlit_public_test: Test

I don’t understand what’s happening. How come the bug only happens in my private repo?

Best,

Antoine

1 Like

By the way I have the same error with gsheetsdb.

1 Like

I did a new test with the exact same python file ( streamlit_public_test/gsheets_public_test.py at main · a455bcd9/streamlit_public_test · GitHub ) in my private and in my public repo and the exact same requirements.txt file: the Streamlit app works on the public repo but not on the private one… I don’t understand…

Do you have a typo in the file name of your private repo?

Files in the private and public repo have exactly the same name and same content.

OK, I solved the problem:

  • The documentation first recommends to use pipenv and Pipfile for dependencies
  • But the next page says: “1. Put your app in a public GitHub repo (and make sure it has a requirements.txt!)”

I deleted my requirements.txt file and instead put the dependencies in Pipfile => it worked.

I think the documentation should be updated accordingly. (see also here for instance)

1 Like

Both work, but not at the same time. There are priorities. That’s actually described pretty clearly here:

App dependencies - Streamlit Docs

Thanks but for a normal user who reads the documentation in order the first page is “Installation” where you’re told to use Pipfile and the next page is “Create an app” where you’re told to “make sure it has a requirements.txt!”.

It would be great to add a link to that page (“App dependencies”) in the “Installation” page of the documentation. And to mention clearly there that “You should only use one requirements file for your app. If you include more than one (e.g. requirements.txt and Pipfile). Streamlit will first look in the directory of your Streamlit app; however, if no requirements file is found, Streamlit will then look at the root of the repo.”

Anyway, thanks a lot for your help :slight_smile:

2 Likes

Hi @a455bcd9,

That’s valuable feedback! Thank you! Would you mind creating an issue in the docs repo (or a PR if you’re feeling altruistic)? We’ll work on making the installation and app dependencies sections more clear. :smile:

Best, :balloon:
Snehan

1 Like

Already did it:

2 Likes

Ah, you’re right, instead of complaining I should have created a PR :wink: , thanks for reminding me :slight_smile:

And thanks a lot @Franky1 for doing it!

Thanks @Franky1 and @snehankekre! :raised_hands:

Glad the issue is now sorted @a455bcd9! :slight_smile:

Best,
Charly