Deploy a Streamlit app from GitHub - # Error installing requirements

Hello I receive this error when deploying through GitHub. I appreciate any help.

Error installing requirements.

Welcome to the community!
Please provide a link to your public github repo, otherwise we can only guess…
I am guessing that you have an invalid entry in your requirements.txt file.
Probably you want to install vaderSentiment instead?

Thanks Franky1

These entries are invalid and i don’t see in your code where you use them?
If you need these libraries in the future, read their documentation, what these packages are called and how to install them.

  1. First step, just keep these entries in your requirements.txt file:
pandas
Pillow
streamlit
  1. Second step, your code will not run anyway, because you reference your local filesystem dozens of times:
# for example:
image = Image.open("Users/ozkay/Trek1500sentst.png")
# another example:
df = pd.read_csv("Users/ozkay/kwTrek1500.csv")

If you need these .png and .csv files, they have to be also in the github repo and you have to adjust all these filepaths. Or load them from another online source.


Moreover, this way of hard coding all the identical blocks beginning with

if option == 'Trek1500':
    # same content here for every block...

is very inefficient and write intensive, you need almost 1000 lines for it…

Ok this is my first experience with github and streamlit.

  1. First step, just keep these entries in your requirements.txt file:

Do I need to use their versions?

If you need these .png and .csv files, they have to be also in the github repo and you have to adjust all these filepaths. Or load them from another online source.:

I uploaded all png s and csv files but how can I adjust these file path s now?

Moreover, this way of hard coding all the identical blocks beginning with:

as bikes strength and weakness have different image and tables, I thought that I have write all codes differently, any idea?

No, it is not mandatory.
But you can pin the versions to ensure no dependency issues in future deployments.

  1. never use filepaths with spaces, use instead for example csv_files and png_files
  2. put all the png files into one folder instead of two
  3. adjust the file paths, examples see below:
image = Image.open("png_files/Trek1500sentst.png")
df = pd.read_csv("csv_files/kwTrek1500.csv")

Yes, one possibility:
Put all the bike’s parameters into a list of dictionaries. Or load the parameters from a json or csv file.
Fill the block after

if option == 'Trek1500':`

dynamically with the parameters instead of hard-coding dozens of bikes over hundreds of lines of code.

Or even better, if the csv and png files are named according to a strict scheme, you can even determine the parameters dynamically from the filesystem. Then i promise, you can write your code in under 100 lines of code!

I appreciate your advise Franky1, thank you.

“Or even better, if the csv and png files are named according to a strict scheme, you can even determine the parameters dynamically from the filesystem. Then i promise, you can write your code in under 100 lines of code!”

You mean I will load them into dict or dataframe with a certain names, then I will use them systematically? Can you pls give a sample code to understand better?

See my fork and pull-request of your github, i refactored your app:

120 LOC :sunglasses:

Still some things to do, a few filenames must be renamed to follow a scheme.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.