How to install Linux binaries when packages.txt does not work

I can’t get a program to run on the streamlit cloud because it can’t install google-cloud-cli. It will run locally with streamlit run application.py and then it works if I go to localhost:8501. On my local machine to make this happen I have installed the google-cloud-cli.

I have google-cloud-cli in the packages.txt file for it to run on streamlit cloud, but it doesn’t work. As you can see on Install the gcloud CLI  |  Google Cloud, if you want to install google-cloud-cli through apt you have to add Google’s debian install channels by making some changes in the /etc/apt/sources.list folder where apt looks to find locations to install packages.

This means you have to run some curl and tee and echo and pipe and apt-key commands as you can see from that page. Since packages.txt seems to be a wrapper around calling apt-get, how do you achieve the above? How do you install a package that is not in the usual debian apt channels?

Here is the error message:

[09:13:58] 📦 Apt dependencies were installed from /app/streamlit-app-2/packages.txt using apt-get.
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:3 http://security.debian.org/debian-security stretch/updates InRelease [53.0 kB]
Get:4 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:5 https://packages.microsoft.com/debian/10/prod buster InRelease [29.8 kB]
Get:6 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [164 kB]
Get:7 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB]
Get:8 https://packages.microsoft.com/debian/10/prod buster/main amd64 Packages [177 kB]
Fetched 8805 kB in 2s (5236 kB/s)
Reading package lists...[2022-07-12 09:14:01.353037] 
Reading package lists...[2022-07-12 09:14:02.112266] 
Building dependency tree...[2022-07-12 09:14:02.328610] 
Reading state information...[2022-07-12 09:14:02.328989] 
E: Unable to locate package google-cloud-cli
1 Like

Hi @KCTEDTEST, welcome to the Streamlit Community! :wave: :partying_face:

Really good question! We need to document this feature:

Install packages outside of apt / the standard package repository on Streamlit Cloud

Here’s how you can install google-cloud-cli:

Step 1: Create a apt.keys with the package’s public key

Create a apt.keys file with the package’s public PGP key:

Click to view apt.keys
-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBGA9EFkBCAC1ilz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7LQ
1aDyhKS6JB7v4HmwsH0/5/VNXaJRSKL4OnigApecTsfq83AFae0eD+du4337nc93
SjHS4T67LRtMOWG8nzz8FjDj6fpFBeOXmHUe5CipNPVayTZBBidCkEOopqkdU59J
MruHL5H6pwlBdK65+wnQai0gr9UEYYK+kwoUH+8p1rD8+YBnVY4d7SM=
=pRoV
-----END PGP PUBLIC KEY BLOCK-----

Step 2: Create a sources.list with the package’s Debian repo

Upload a sources.list file with gcloud’s Debian repo:

sources.list
deb https://packages.cloud.google.com/apt cloud-sdk main

Step 3: Add the package to packages.txt

Add google-cloud-cli to a packages.txt file:

packages.txt
google-cloud-cli

Once you implement all three steps, gcloud CLI should be successfully installed on Streamlit Cloud!

Here’s a demo repo with the above changes: GitHub - snehankekre/gcloud-cli-streamlit-cloud

Happy Streamlit-ing! :balloon:
Snehan

4 Likes

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