Application running locally but not getting deployed on Streamlit Cloud

My application is running when I run it locally. But it is not getting deployed on Streamlit Cloud.
Link to the Github Repo is apurbanand/knowledge_gpt_authorized

I am getting the following error.

Blockquote
Collecting pytz-deprecation-shim==0.1.0.post0
Downloading pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB)
ERROR: Could not find a version that satisfies the requirement pywin32>=300 (from versions: none)
ERROR: No matching distribution found for pywin32>=300
WARNING: You are using pip version 22.0.3; however, version 23.2.1 is available.
You should consider upgrading via the β€˜/home/adminuser/venv/bin/python -m pip install --upgrade pip’ command.
Checking if Streamlit is installed
────────────────────────────────────────────────────────────────────────────────────────
[15:32:54] :exclamation: installer returned a non-zero exit code
[15:32:54] :exclamation: Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[15:34:31] :exclamation: Streamlit server consistently failed status checks
[15:34:31] :exclamation: Please fix the errors, push an update to the git repo, or reboot the app.

Blockquote


The main.py file  - knowledge_gpt_authorized/knowledge_gpt
/main.py

import streamlit as st
import toml
import os

# Set the working directory to the script's directory
script_directory = os.path.dirname(os.path.abspath(__file__))
os.chdir(script_directory)

# Load authorized email IDs from secrets.toml
secrets = toml.load("secrets.toml")
authorized_emails = secrets["auth"]["authorized_emails"]

# Initialize user_email as None
user_email = None

# Set Streamlit page configuration
st.set_page_config(page_title="KnowledgeGPT", page_icon="πŸ“–", layout="wide")

# Define the login page function
def login_page():
    global user_email
    st.title("Login")
    email = st.text_input("Email:")
    password = st.text_input("Password:", type="password")
    login_button = st.button("Log In")

    if login_button:
        if email in authorized_emails:
            st.success("Login successful!")
            user_email = email  # Assign the email
        else:
            st.error("Unauthorized email. Please try again.")

# Call the login page function
login_page()

# Check if user_email is set and authorized
if user_email is None:
    st.warning("Unauthorized access. Please log in with an authorized email.")
    st.stop()

# st.write(authorized_emails)
# st.write(user_email)

# The rest of your Streamlit application code goes here...
def main():
    if "user_email" in st.session_state:
        user_email = st.session_state.user_email

        # Check if the user's email is authorized
        if user_email not in authorized_emails:
            st.warning("Unauthorized access. Please log in with an authorized email.")
            st.stop()

        # The rest of your Streamlit application code goes here

if __name__ == "__main__":
    main()

from knowledge_gpt.components.sidebar import sidebar
from knowledge_gpt.ui import (
    wrap_doc_in_html,
    is_query_valid,
    is_file_valid,
    is_open_ai_key_valid,
    display_file_read_error,
)
from knowledge_gpt.core.caching import bootstrap_caching
from knowledge_gpt.core.parsing import read_file
from knowledge_gpt.core.chunking import chunk_file
from knowledge_gpt.core.embedding import embed_files
from knowledge_gpt.core.qa import query_folder
from knowledge_gpt.core.utils import get_llm

EMBEDDING = "openai"
VECTOR_STORE = "faiss"
MODEL_LIST = ["gpt-3.5-turbo", "gpt-4"]

# Uncomment to enable debug mode
# MODEL_LIST.insert(0, "debug")

st.header("πŸ“–KnowledgeGPT")

# Enable caching for expensive functions
bootstrap_caching()

sidebar()

openai_api_key = st.session_state.get("OPENAI_API_KEY")

if not openai_api_key:
    st.warning(
        "Enter your OpenAI API key in the sidebar. You can get a key at"
        " https://platform.openai.com/account/api-keys."
    )

uploaded_file = st.file_uploader(
    "Upload a pdf, docx, or txt file",
    type=["pdf", "docx", "txt"],
    help="Scanned documents are not supported yet!",
)

model: str = st.selectbox("Model", options=MODEL_LIST)  # type: ignore

with st.expander("Advanced Options"):
    return_all_chunks = st.checkbox("Show all chunks retrieved from vector search")
    show_full_doc = st.checkbox("Show parsed contents of the document")

if not uploaded_file:
    st.stop()

try:
    file = read_file(uploaded_file)
except Exception as e:
    display_file_read_error(e, file_name=uploaded_file.name)

chunked_file = chunk_file(file, chunk_size=300, chunk_overlap=0)

if not is_file_valid(file):
    st.stop()

if not is_open_ai_key_valid(openai_api_key, model):
    st.stop()

with st.spinner("Indexing document... This may take a while⏳"):
    folder_index = embed_files(
        files=[chunked_file],
        embedding=EMBEDDING if model != "debug" else "debug",
        vector_store=VECTOR_STORE if model != "debug" else "debug",
        openai_api_key=openai_api_key,
    )

with st.form(key="qa_form"):
    query = st.text_area("Ask a question about the document")
    submit = st.form_submit_button("Submit")

if show_full_doc:
    with st.expander("Document"):
        # Hack to get around st.markdown rendering LaTeX
        st.markdown(f"<p>{wrap_doc_in_html(file.docs)}</p>", unsafe_allow_html=True)

if submit:
    if not is_query_valid(query):
        st.stop()

    # Output Columns
    answer_col, sources_col = st.columns(2)

    llm = get_llm(model=model, openai_api_key=openai_api_key, temperature=0)
    result = query_folder(
        folder_index=folder_index,
        query=query,
        return_all=return_all_chunks,
        llm=llm,
    )

    with answer_col:
        st.markdown("#### Answer")
        st.markdown(result.answer)

    with sources_col:
        st.markdown("#### Sources")
        for source in result.sources:
            st.markdown(source.page_content)
            st.markdown(source.metadata["source"])
            st.markdown("---")**strong text**

Blockquote
The requirements.txt file is as below
Blockquote

ο»Ώaiohttp==3.8.5
aiosignal==1.3.1
altair==5.0.1
asttokens==2.2.1
async-timeout==4.0.2
attrs==23.1.0
backcall==0.2.0
black==23.7.0
blinker==1.6.2
cachetools==5.3.1
certifi==2023.7.22
charset-normalizer==3.2.0
click==8.1.6
cohere==3.10.0
colorama==0.4.6
comm==0.1.3
dataclasses-json==0.5.9
debugpy==1.6.7
decorator==5.1.1
docx2txt==0.8
executing==1.2.0
faiss-cpu==1.7.4
filelock==3.12.3
flake8==6.0.0
frozenlist==1.4.0
fsspec==2023.9.0
gitdb==4.0.10
GitPython==3.1.32
greenlet==2.0.2
huggingface-hub==0.16.4
idna==3.4
importlib-metadata==6.8.0
iniconfig==2.0.0
ipykernel==6.25.1
ipython==8.14.0
ipywidgets==8.0.7
isort==5.12.0
jedi==0.18.2
Jinja2==3.1.2
jsonschema==4.18.4
jsonschema-specifications==2023.7.1
jupyter_client==8.3.0
jupyter_core==5.3.1
jupyterlab-widgets==3.0.8
-e git+https://github.com/mmz-001/knowledge_gpt@6002862f69489a81f1bc39d0eb265a6960362f48#egg=knowledge_gpt
langchain==0.0.220
langchainplus-sdk==0.0.20
markdown-it-py==3.0.0
MarkupSafe==2.1.3
marshmallow==3.20.1
marshmallow-enum==1.5.1
matplotlib-inline==0.1.6
mccabe==0.7.0
mdurl==0.1.2
multidict==6.0.4
mypy-extensions==1.0.0
nest-asyncio==1.5.6
numexpr==2.8.4
numpy==1.25.1
openai==0.27.8
openapi-schema-pydantic==1.2.4
packaging==23.1
pandas==2.0.3
parso==0.8.3
pathspec==0.11.1
pickleshare==0.7.5
Pillow==9.5.0
platformdirs==3.9.1
pluggy==1.2.0
prompt-toolkit==3.0.39
protobuf==4.23.4
psutil==5.9.5
pure-eval==0.2.2
pyarrow==12.0.1
pycodestyle==2.10.0
pycryptodome==3.18.0
pydantic==1.10.11
pydeck==0.8.0
pyflakes==3.0.1
Pygments==2.15.1
Pympler==1.0.1
PyMuPDF==1.22.5
pytest==7.4.0
python-dateutil==2.8.2
python-dotenv==0.21.1
pytz==2023.3
pytz-deprecation-shim==0.1.0.post0
pywin32==306
PyYAML==6.0.1
pyzmq==25.1.0
referencing==0.30.0
regex==2023.6.3
requests==2.31.0
rich==13.4.2
rpds-py==0.9.2
safetensors==0.3.3
six==1.16.0
smmap==5.0.0
SQLAlchemy==2.0.19
stack-data==0.6.2
streamlit==1.25.0
tenacity==8.2.2
tiktoken==0.4.0
tokenizers==0.13.3
toml==0.10.2
toolz==0.12.0
tornado==6.3.2
tqdm==4.65.0
traitlets==5.9.0
transformers==4.33.1
typing-inspect==0.9.0
typing_extensions==4.7.1
tzdata==2023.3
tzlocal==4.3.14
urllib3==1.26.16
validators==0.20.0
watchdog==3.0.0
wcwidth==0.2.6
widgetsnbextension==4.0.8
yarl==1.9.2
zipp==3.16.2

Hey @Apurb_Anand,

Thanks for sharing this question! Please update your post to format your code properly and share links to your GitHub repo and your deployed app.

Hope my post is in order now. Being the first post, I missed the option to format the post. But your message made me aware about it. Thanks for guiding me.

1 Like

Thank you! It looks like removing pywin32 from your requirements.txt file should resolve this error. Check out this related thread.

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