I had no luck via the requirements.txt route either What worked was installing the package in the main app script itself via a subprocess.
Say your script is streamlit_app.py. Include the following at the very top of your app:
import streamlit as st
import subprocess
import sys
import time
try:
# replace "yourpackage" with the package you want to import
import yourpackage
# This block executes only on the first run when your package isn't installed
except ModuleNotFoundError as e:
subprocess.Popen([f'{sys.executable} -m pip install git+https://${{token}}@github.com/yourusername/yourrepo.git'], shell=True)
# wait for subprocess to install package before running your actual code below
time.sleep(90)
# Rest of your code goes here
import yourpackage
st.write(yourpackage.somefunc())
In the secrets management console paste in your token like so:
I am facing the same problem when trying to install a private GitHub repo and unfortunately keep getting the error
fatal: could not read Username for 'https://github.com': No such device or address
error: subprocess-exited-with-error
even after I tried the proposed solution of @snehankekre to generate the personal access token and install the package in the main script. Did anybody come up with a workaround in the mean time or made it work with the proposed code?
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.
Cookie settings
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.