Requirements.txt Error

If you’re creating a debugging post, please include the following info:

  1. This is the link : https://nortoninsightgenerator.streamlit.app/(deployed on Community Cloud).
  2. Full text of error message: Error installing requirements.

Click “Manage App” and consult the terminal for more details.

If you still have questions, leave a message in our forums and we will get back to you ASAP…

Please can you copy the full error logs. Before it says “Error installing requirements” there should be more information about each package it installed and what error it encountered.

These are the error logs:

Error installing requirements.

Click “Manage App” and consult the terminal for more details.

If you still have questions, leave a message in our forums and we will get back to you ASAP.

[     UTC     ] Logs for nortoninsightgenerator.streamlit.app/
────────────────────────────────────────────────────────────────────────────────────────
[05:14:09] 🖥 Provisioning machine...
[05:14:12] 🎛 Preparing system...
[05:14:12] ⛓ Spinning up manager process...
[05:14:20] 🖥 Provisioning machine...
[05:14:45] 🎛 Preparing system...
[05:14:48] ⛓ Spinning up manager process...
[05:14:20] 🚀 Starting up repository: 'insightgenerator', branch: 'main', main module: 'Azure_Analysis.py'
[05:14:20] 🐙 Cloning repository...
[05:14:21] 🐙 Cloning into '/mount/src/insightgenerator'...
[05:14:21] 🐙 Cloned repository!
[05:14:21] 🐙 Pulling code changes from Github...
[05:14:21] 📦 Processing dependencies...

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.
  × No solution found when resolving dependencies:[2024-10-28 05:14:22.561247] 
  ╰─▶ Because os was not found in the package registry and you require os, we
      can conclude that the requirements are unsatisfiable.[2024-10-28 05:14:22.561794] 
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────


──────────────────────────────────────── pip ───────────────────────────────────────────

Using standard pip install.
Collecting streamlit (from -r /mount/src/insightgenerator/requirements.txt (line 1))
  Downloading streamlit-1.39.0-py2.py3-none-any.whl.metadata (8.5 kB)
ERROR: Ignored the following versions that require a different python version: 0.55.2 Requires-Python <3.5
ERROR: Could not find a version that satisfies the requirement os (from versions: none)
ERROR: No matching distribution found for os

[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[05:14:25] ❗️ installer returned a non-zero exit code
[05:14:25] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[05:14:20] 🚀 Starting up repository: 'insightgenerator', branch: 'main', main module: 'Azure_Analysis.py'
[05:14:20] 🐙 Cloning repository...
[05:14:21] 🐙 Cloning into '/mount/src/insightgenerator'...
[05:14:21] 🐙 Cloned repository!
[05:14:21] 🐙 Pulling code changes from Github...
[05:14:21] 📦 Processing dependencies...

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.
  × No solution found when resolving dependencies:[2024-10-28 05:14:22.561247] 
  ╰─▶ Because os was not found in the package registry and you require os, we
      can conclude that the requirements are unsatisfiable.[2024-10-28 05:14:22.561794] 
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────


──────────────────────────────────────── pip ───────────────────────────────────────────

Using standard pip install.
Collecting streamlit (from -r /mount/src/insightgenerator/requirements.txt (line 1))
  Downloading streamlit-1.39.0-py2.py3-none-any.whl.metadata (8.5 kB)
ERROR: Ignored the following versions that require a different python version: 0.55.2 Requires-Python <3.5
ERROR: Could not find a version that satisfies the requirement os (from versions: none)
ERROR: No matching distribution found for os

[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[05:14:25] ❗️ installer returned a non-zero exit code
[05:14:25] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[05:16:00] ❗️ Streamlit server consistently failed status checks
[05:16:00] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.
[05:14:20] 🚀 Starting up repository: 'insightgenerator', branch: 'main', main module: 'Azure_Analysis.py'
[05:14:20] 🐙 Cloning repository...
[05:14:21] 🐙 Cloning into '/mount/src/insightgenerator'...
[05:14:21] 🐙 Cloned repository!
[05:14:21] 🐙 Pulling code changes from Github...
[05:14:21] 📦 Processing dependencies...

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.
  × No solution found when resolving dependencies:[2024-10-28 05:14:22.561247] 
  ╰─▶ Because os was not found in the package registry and you require os, we
      can conclude that the requirements are unsatisfiable.[2024-10-28 05:14:22.561794] 
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────


──────────────────────────────────────── pip ───────────────────────────────────────────

Using standard pip install.
Collecting streamlit (from -r /mount/src/insightgenerator/requirements.txt (line 1))
  Downloading streamlit-1.39.0-py2.py3-none-any.whl.metadata (8.5 kB)
ERROR: Ignored the following versions that require a different python version: 0.55.2 Requires-Python <3.5
ERROR: Could not find a version that satisfies the requirement os (from versions: none)
ERROR: No matching distribution found for os

[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[05:14:25] ❗️ installer returned a non-zero exit code
[05:14:25] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[05:16:00] ❗️ Streamlit server consistently failed status checks
[05:16:00] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.
[05:14:20] 🚀 Starting up repository: 'insightgenerator', branch: 'main', main module: 'Azure_Analysis.py'
[05:14:20] 🐙 Cloning repository...
[05:14:21] 🐙 Cloning into '/mount/src/insightgenerator'...
[05:14:21] 🐙 Cloned repository!
[05:14:21] 🐙 Pulling code changes from Github...
[05:14:21] 📦 Processing dependencies...

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.
  × No solution found when resolving dependencies:[2024-10-28 05:14:22.561247] 
  ╰─▶ Because os was not found in the package registry and you require os, we
      can conclude that the requirements are unsatisfiable.[2024-10-28 05:14:22.561794] 
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────


──────────────────────────────────────── pip ───────────────────────────────────────────

Using standard pip install.
Collecting streamlit (from -r /mount/src/insightgenerator/requirements.txt (line 1))
  Downloading streamlit-1.39.0-py2.py3-none-any.whl.metadata (8.5 kB)
ERROR: Ignored the following versions that require a different python version: 0.55.2 Requires-Python <3.5
ERROR: Could not find a version that satisfies the requirement os (from versions: none)
ERROR: No matching distribution found for os

[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[05:14:25] ❗️ installer returned a non-zero exit code
[05:14:25] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[05:16:00] ❗️ Streamlit server consistently failed status checks
[05:16:00] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.
[05:14:20] 🚀 Starting up repository: 'insightgenerator', branch: 'main', main module: 'Azure_Analysis.py'
[05:14:20] 🐙 Cloning repository...
[05:14:21] 🐙 Cloning into '/mount/src/insightgenerator'...
[05:14:21] 🐙 Cloned repository!
[05:14:21] 🐙 Pulling code changes from Github...
[05:14:21] 📦 Processing dependencies...

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.
  × No solution found when resolving dependencies:[2024-10-28 05:14:22.561247] 
  ╰─▶ Because os was not found in the package registry and you require os, we
      can conclude that the requirements are unsatisfiable.[2024-10-28 05:14:22.561794] 
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────


──────────────────────────────────────── pip ───────────────────────────────────────────

Using standard pip install.
Collecting streamlit (from -r /mount/src/insightgenerator/requirements.txt (line 1))
  Downloading streamlit-1.39.0-py2.py3-none-any.whl.metadata (8.5 kB)
ERROR: Ignored the following versions that require a different python version: 0.55.2 Requires-Python <3.5
ERROR: Could not find a version that satisfies the requirement os (from versions: none)
ERROR: No matching distribution found for os

[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[05:14:25] ❗️ installer returned a non-zero exit code
[05:14:25] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[05:16:00] ❗️ Streamlit server consistently failed status checks
[05:16:00] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.
[05:14:20] 🚀 Starting up repository: 'insightgenerator', branch: 'main', main module: 'Azure_Analysis.py'
[05:14:20] 🐙 Cloning repository...
[05:14:21] 🐙 Cloning into '/mount/src/insightgenerator'...
[05:14:21] 🐙 Cloned repository!
[05:14:21] 🐙 Pulling code changes from Github...
[05:14:21] 📦 Processing dependencies...

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.
  × No solution found when resolving dependencies:[2024-10-28 05:14:22.561247] 
  ╰─▶ Because os was not found in the package registry and you require os, we
      can conclude that the requirements are unsatisfiable.[2024-10-28 05:14:22.561794] 
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────


──────────────────────────────────────── pip ───────────────────────────────────────────

Using standard pip install.
Collecting streamlit (from -r /mount/src/insightgenerator/requirements.txt (line 1))
  Downloading streamlit-1.39.0-py2.py3-none-any.whl.metadata (8.5 kB)
ERROR: Ignored the following versions that require a different python version: 0.55.2 Requires-Python <3.5
ERROR: Could not find a version that satisfies the requirement os (from versions: none)
ERROR: No matching distribution found for os

[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[05:14:25] ❗️ installer returned a non-zero exit code
[05:14:25] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[05:16:00] ❗️ Streamlit server consistently failed status checks
[05:16:00] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.

The logs say:

× No solution found when resolving dependencies…╰─▶ Because os was not found in the package registry and you require os

os is part of Python and shouldn’t be included in your requirements file. It’s not something you pip install. Try removing os from requirements.txt.

Ok but if I do that, I now face this problem because os is required for getting my LLM model’s api key and endpoint:

endpoint = os.environ[“AZURE_OPENAI_BASE”]
api_key = os.environ[“AZURE_OPENAI_API_KEY”]
print(f"Endpoint: {endpoint}, API Key: {api_key}")
client = AzureOpenAI(
api_version=“2024-02-01”,
azure_endpoint=endpoint,
api_key=api_key
)

I get this error now:

KeyError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

Traceback:

File "/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
    result = func()
             ^^^^^^File "/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
    exec(code, module.__dict__)File "/mount/src/insightgenerator/Azure_Analysis.py", line 114, in <module>
    endpoint = os.environ["AZURE_OPENAI_BASE"]
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^File "<frozen os>", line 714, in __getitem__

Full logs:

KeyError: 'AZURE_OPENAI_BASE'
2024-10-28 09:22:11.361 503 GET /script-health-check (127.0.0.1) 371.93ms
────────────────────── Traceback (most recent call last) ───────────────────────
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/exec_code.py:88 in exec_func_with_error_handling                         
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/script_runner.py:579 in code_to_exec                                     
                                                                                
  /mount/src/insightgenerator/Azure_Analysis.py:114 in <module>                 
                                                                                
    111 ssl._create_default_https_context = ssl._create_unverified_context      
    112 os.environ['CURL_CA_BUNDLE'] = ''                                       
    113 os.environ['REQUESTS_CA_BUNDLE'] = ''                                   
  ❱ 114 endpoint = os.environ["AZURE_OPENAI_BASE"]                              
    115 api_key = os.environ["AZURE_OPENAI_API_KEY"]                            
    116 print(f"Endpoint: {endpoint}, API Key: {api_key}")                      
    117 client = AzureOpenAI(                                                   
  in __getitem__:714                                                            
────────────────────────────────────────────────────────────────────────────────
KeyError: 'AZURE_OPENAI_BASE'
2024-10-28 09:22:16.199 503 GET /script-health-check (127.0.0.1) 340.41ms
────────────────────── Traceback (most recent call last) ───────────────────────
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/exec_code.py:88 in exec_func_with_error_handling                         
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/script_runner.py:579 in code_to_exec                                     
                                                                                
  /mount/src/insightgenerator/Azure_Analysis.py:114 in <module>                 
                                                                                
    111 ssl._create_default_https_context = ssl._create_unverified_context      
    112 os.environ['CURL_CA_BUNDLE'] = ''                                       
    113 os.environ['REQUESTS_CA_BUNDLE'] = ''                                   
  ❱ 114 endpoint = os.environ["AZURE_OPENAI_BASE"]                              
    115 api_key = os.environ["AZURE_OPENAI_API_KEY"]                            
    116 print(f"Endpoint: {endpoint}, API Key: {api_key}")                      
    117 client = AzureOpenAI(                                                   
  in __getitem__:714                                                            
────────────────────────────────────────────────────────────────────────────────
KeyError: 'AZURE_OPENAI_BASE'
2024-10-28 09:22:21.236 503 GET /script-health-check (127.0.0.1) 362.75ms
────────────────────── Traceback (most recent call last) ───────────────────────
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/exec_code.py:88 in exec_func_with_error_handling                         
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/script_runner.py:579 in code_to_exec                                     
                                                                                
  /mount/src/insightgenerator/Azure_Analysis.py:114 in <module>                 
                                                                                
    111 ssl._create_default_https_context = ssl._create_unverified_context      
    112 os.environ['CURL_CA_BUNDLE'] = ''                                       
    113 os.environ['REQUESTS_CA_BUNDLE'] = ''                                   
  ❱ 114 endpoint = os.environ["AZURE_OPENAI_BASE"]                              
    115 api_key = os.environ["AZURE_OPENAI_API_KEY"]                            
    116 print(f"Endpoint: {endpoint}, API Key: {api_key}")                      
    117 client = AzureOpenAI(                                                   
  in __getitem__:714                                                            
────────────────────────────────────────────────────────────────────────────────
KeyError: 'AZURE_OPENAI_BASE'
2024-10-28 09:22:26.297 503 GET /script-health-check (127.0.0.1) 327.16ms

You need to define your environment variables for Community Cloud. That isn’t an issue of installing or importing os. You need to configure your app’s secrets.

You need to define AZURE_OPENAI_BASE.

1 Like

Hi so thanks for letting me know about the secrets feature that solved that specific issue. But now Im facing this problem where it says the app is running but nothing is actually being displayed or being processed:

Will it always take a very long time to generate everything in the site when using streamlit cloud?

I think I’ve been waiting 20+ minutes for it to display the full site, but no change seems to have happened. I also added a white background in my markdown but that also isn’t shown.

Edit: I got these error logs after waiting:

[05:49:33] 🐙 Pulling code changes from Github...
[05:49:34] 📦 Processing dependencies...
[05:49:34] 📦 Processed dependencies!
[05:49:35] 🔄 Updated app!
────────────────────── Traceback (most recent call last) ───────────────────────
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/exec_code.py:88 in exec_func_with_error_handling                         
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/script_runner.py:579 in code_to_exec                                     
                                                                                
  /mount/src/insightgenerator/Azure_Analysis.py:197 in <module>                 
                                                                                
    194 │   pdf.add_summary(categories_summary)                                 
    195 │   pdf.output(file_path)                                               
    196 │   return file_path                                                    
  ❱ 197 clients = bigquery.Client(project='ppp-cdo-rep-ext-6c')                 
    198 downloads_path = str(pathlib.Path.home() / "Downloads")                 
    199 output_csv_path = os.path.join(downloads_path, 'rating_feedback_result  
    200 query = """                                                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/clie  
  nt.py:269 in __init__                                                         
                                                                                
     266 │   │   │   │   )                                                      
     267 │   │   # Ensure credentials and universe are not in conflict.         
     268 │   │   if hasattr(self, "_credentials") and client_universe is not N  
  ❱  269 │   │   │   _validate_universe(client_universe, self._credentials)     
     270 │   │                                                                  
     271 │   │   self._connection = Connection(self, **kw_args)                 
     272 │   │   self._location = location                                      
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/_hel  
  pers.py:114 in _validate_universe                                             
                                                                                
     111 │   Raises:                                                            
     112 │   │   ValueError: when client_universe does not match the universe   
     113 │   """                                                                
  ❱  114 │   if hasattr(credentials, "universe_domain"):                        
     115 │   │   cred_universe = getattr(credentials, "universe_domain")        
     116 │   │   if isinstance(cred_universe, str):                             
     117 │   │   │   if client_universe != cred_universe:                       
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /credentials.py:154 in universe_domain                                        
                                                                                
    151 │   │                                                                   
    152 │   │   from google.auth.transport import requests as google_auth_requ  
    153 │   │                                                                   
  ❱ 154 │   │   self._universe_domain = _metadata.get_universe_domain(          
    155 │   │   │   google_auth_requests.Request()                              
    156 │   │   )                                                               
    157 │   │   self._universe_domain_cached = True                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /_metadata.py:296 in get_universe_domain                                      
                                                                                
    293 │   │   google.auth.exceptions.TransportError: if an error other than   
    294 │   │   │   404 occurs while retrieving metadata.                       
    295 │   """                                                                 
  ❱ 296 │   universe_domain = get(                                              
    297 │   │   request, "universe/universe_domain", return_none_for_not_found  
    298 │   )                                                                   
    299 │   if not universe_domain:                                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /_metadata.py:229 in get                                                      
                                                                                
    226 │   │   │   │   e,                                                      
    227 │   │   │   )                                                           
    228 │   else:                                                               
  ❱ 229 │   │   raise exceptions.TransportError(                                
    230 │   │   │   "Failed to retrieve {} from the Google Compute Engine "     
    231 │   │   │   "metadata service. Compute Engine Metadata server unavaila  
    232 │   │   )                                                               
────────────────────────────────────────────────────────────────────────────────
TransportError: Failed to retrieve 
http://metadata.google.internal/computeMetadata/v1/universe/universe_domain from
the Google Compute Engine metadata service. Compute Engine Metadata server 
unavailable
────────────────────── Traceback (most recent call last) ───────────────────────
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/exec_code.py:88 in exec_func_with_error_handling                         
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/script_runner.py:579 in code_to_exec                                     
                                                                                
  /mount/src/insightgenerator/Azure_Analysis.py:197 in <module>                 
                                                                                
     194 │   │   else:                                                          
     195 │   │   │   vis_data.plot(ax=ax, kind='bar', title=vis_name)           
     196 │   │   pdf.add_figure(fig)                                            
  ❱  197 │   │   plt.close(fig)                                                 
     198 │   │   insight_text = all_insights.get(vis_name, "")                  
     199 │   │   pdf.add_insight(f"Insights for {vis_name}", insight_text)      
     200 │   return pdf.output(dest='S').encode('latin1')                       
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/clie  
  nt.py:269 in __init__                                                         
                                                                                
     266 │   │   │   │   )                                                      
     267 │   │   # Ensure credentials and universe are not in conflict.         
     268 │   │   if hasattr(self, "_credentials") and client_universe is not N  
  ❱  269 │   │   │   _validate_universe(client_universe, self._credentials)     
     270 │   │                                                                  
     271 │   │   self._connection = Connection(self, **kw_args)                 
     272 │   │   self._location = location                                      
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/_hel  
  pers.py:114 in _validate_universe                                             
                                                                                
     111 │   Raises:                                                            
     112 │   │   ValueError: when client_universe does not match the universe   
     113 │   """                                                                
  ❱  114 │   if hasattr(credentials, "universe_domain"):                        
     115 │   │   cred_universe = getattr(credentials, "universe_domain")        
     116 │   │   if isinstance(cred_universe, str):                             
     117 │   │   │   if client_universe != cred_universe:                       
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /credentials.py:154 in universe_domain                                        
                                                                                
    151 │   │                                                                   
    152 │   │   from google.auth.transport import requests as google_auth_requ  
    153 │   │                                                                   
  ❱ 154 │   │   self._universe_domain = _metadata.get_universe_domain(          
    155 │   │   │   google_auth_requests.Request()                              
    156 │   │   )                                                               
    157 │   │   self._universe_domain_cached = True                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /_metadata.py:296 in get_universe_domain                                      
                                                                                
    293 │   │   google.auth.exceptions.TransportError: if an error other than   
    294 │   │   │   404 occurs while retrieving metadata.                       
    295 │   """                                                                 
  ❱ 296 │   universe_domain = get(                                              
    297 │   │   request, "universe/universe_domain", return_none_for_not_found  
    298 │   )                                                                   
    299 │   if not universe_domain:                                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /_metadata.py:229 in get                                                      
                                                                                
    226 │   │   │   │   e,                                                      
    227 │   │   │   )                                                           
    228 │   else:                                                               
  ❱ 229 │   │   raise exceptions.TransportError(                                
    230 │   │   │   "Failed to retrieve {} from the Google Compute Engine "     
    231 │   │   │   "metadata service. Compute Engine Metadata server unavaila  
    232 │   │   )                                                               
────────────────────────────────────────────────────────────────────────────────
TransportError: Failed to retrieve 
http://metadata.google.internal/computeMetadata/v1/universe/universe_domain from
the Google Compute Engine metadata service. Compute Engine Metadata server 
unavailable
────────────────────── Traceback (most recent call last) ───────────────────────
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/exec_code.py:88 in exec_func_with_error_handling                         
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/script_runner.py:579 in code_to_exec                                     
                                                                                
  /mount/src/insightgenerator/Azure_Analysis.py:197 in <module>                 
                                                                                
     194 │   │   else:                                                          
     195 │   │   │   vis_data.plot(ax=ax, kind='bar', title=vis_name)           
     196 │   │   pdf.add_figure(fig)                                            
  ❱  197 │   │   plt.close(fig)                                                 
     198 │   │   insight_text = all_insights.get(vis_name, "")                  
     199 │   │   pdf.add_insight(f"Insights for {vis_name}", insight_text)      
     200 │   return pdf.output(dest='S').encode('latin1')                       
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/clie  
  nt.py:269 in __init__                                                         
                                                                                
     266 │   │   │   │   )                                                      
     267 │   │   # Ensure credentials and universe are not in conflict.         
     268 │   │   if hasattr(self, "_credentials") and client_universe is not N  
  ❱  269 │   │   │   _validate_universe(client_universe, self._credentials)     
     270 │   │                                                                  
     271 │   │   self._connection = Connection(self, **kw_args)                 
     272 │   │   self._location = location                                      
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/_hel  
  pers.py:114 in _validate_universe                                             
                                                                                
     111 │   Raises:                                                            
     112 │   │   ValueError: when client_universe does not match the universe   
     113 │   """                                                                
  ❱  114 │   if hasattr(credentials, "universe_domain"):                        
     115 │   │   cred_universe = getattr(credentials, "universe_domain")        
     116 │   │   if isinstance(cred_universe, str):                             
     117 │   │   │   if client_universe != cred_universe:                       
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /credentials.py:154 in universe_domain                                        
                                                                                
    151 │   │                                                                   
    152 │   │   from google.auth.transport import requests as google_auth_requ  
    153 │   │                                                                   
  ❱ 154 │   │   self._universe_domain = _metadata.get_universe_domain(          
    155 │   │   │   google_auth_requests.Request()                              
    156 │   │   )                                                               
    157 │   │   self._universe_domain_cached = True                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /_metadata.py:296 in get_universe_domain                                      
                                                                                
    293 │   │   google.auth.exceptions.TransportError: if an error other than   
    294 │   │   │   404 occurs while retrieving metadata.                       
    295 │   """                                                                 
  ❱ 296 │   universe_domain = get(                                              
    297 │   │   request, "universe/universe_domain", return_none_for_not_found  
    298 │   )                                                                   
    299 │   if not universe_domain:                                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine  
  /_metadata.py:229 in get                                                      
                                                                                
    226 │   │   │   │   e,                                                      
    227 │   │   │   )                                                           
    228 │   else:                                                               
  ❱ 229 │   │   raise exceptions.TransportError(                                
    230 │   │   │   "Failed to retrieve {} from the Google Compute Engine "     
    231 │   │   │   "metadata service. Compute Engine Metadata server unavaila  
    232 │   │   )                                                               
────────────────────────────────────────────────────────────────────────────────
TransportError: Failed to retrieve 
http://metadata.google.internal/computeMetadata/v1/universe/universe_domain from
the Google Compute Engine metadata service. Compute Engine Metadata server 
unavailable

It’s really hard to read the logs without proper formatting. Please can you edit your post to put them in a single code block so it’s easier to read? :smile:

Sorry its also because there’s so many error logs

Maybe this could be more understandable:

[05:49:33] :octopus: Pulling code changes from Github…
[05:49:34] :package: Processing dependencies…
[05:49:34] :package: Processed dependencies!
[05:49:35] :arrows_counterclockwise: Updated app!
────────────────────── Traceback (most recent call last) ───────────────────────
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/exec_code.py:88 in exec_func_with_error_handling

/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/script_runner.py:579 in code_to_exec

/mount/src/insightgenerator/Azure_Analysis.py:197 in
194 │ pdf.add_summary(categories_summary)
195 │ pdf.output(file_path)
196 │ return file_path
❱ 197 │ clients = bigquery.Client(project=‘ppp-cdo-rep-ext-6c’)
198 │ downloads_path = str(pathlib.Path.home() / “Downloads”)
199 │ output_csv_path = os.path.join(downloads_path, 'rating_feedback_result
200 │ query = “”"

/home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/clie
nt.py:269 in init

 266 │   │   │   │   )                                                      
 267 │   │   # Ensure credentials and universe are not in conflict.         
 268 │   │   if hasattr(self, "_credentials") and client_universe is not N  

❱ 269 │ │ │ _validate_universe(client_universe, self._credentials)
270 │ │
271 │ │ self._connection = Connection(self, **kw_args)
272 │ │ self._location = location

/home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/_hel
pers.py:114 in _validate_universe

 111 │   Raises:                                                            
 112 │   │   ValueError: when client_universe does not match the universe   
 113 │   """                                                                

❱ 114 │ if hasattr(credentials, “universe_domain”):
115 │ │ cred_universe = getattr(credentials, “universe_domain”)
116 │ │ if isinstance(cred_universe, str):
117 │ │ │ if client_universe != cred_universe:

/home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine
/credentials.py:154 in universe_domain

151 │   │                                                                   
152 │   │   from google.auth.transport import requests as google_auth_requ  
153 │   │                                                                   

❱ 154 │ │ self._universe_domain = _metadata.get_universe_domain(
155 │ │ │ google_auth_requests.Request()
156 │ │ )
157 │ │ self._universe_domain_cached = True

/home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine
/_metadata.py:296 in get_universe_domain

293 │   │   google.auth.exceptions.TransportError: if an error other than   
294 │   │   │   404 occurs while retrieving metadata.                       
295 │   """                                                                 

❱ 296 │ universe_domain = get(
297 │ │ request, “universe/universe_domain”, return_none_for_not_found
298 │ )
299 │ if not universe_domain:

/home/adminuser/venv/lib/python3.12/site-packages/google/auth/compute_engine
/_metadata.py:229 in get

226 │   │   │   │   e,                                                      
227 │   │   │   )                                                           
228 │   else:                                                               

❱ 229 │ │ raise exceptions.TransportError(
230 │ │ │ "Failed to retrieve {} from the Google Compute Engine "
231 │ │ │ "metadata service. Compute Engine Metadata server unavaila
232 │ │ )
────────────────────────────────────────────────────────────────────────────────
TransportError: Failed to retrieve
http://metadata.google.internal/computeMetadata/v1/universe/universe_domain from
the Google Compute Engine metadata service. Compute Engine Metadata server
unavailable
────────────────────── Traceback (most recent call last) ───────────────────────
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/exec_code.py:88 in exec_func_with_error_handling

/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/script_runner.py:579 in code_to_exec

/mount/src/insightgenerator/Azure_Analysis.py:197 in
194 │ │ else:
195 │ │ │ vis_data.plot(ax=ax, kind=‘bar’, title=vis_name)
196 │ │ pdf.add_figure(fig)
❱ 197 │ │ plt.close(fig)
198 │ │ insight_text = all_insights.get(vis_name, “”)
199 │ │ pdf.add_insight(f"Insights for {vis_name}", insight_text)
200 │ return pdf.output(dest=‘S’).encode(‘latin1’)

/home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/clie
nt.py:269 in init

 266 │   │   │   │   )                                                      
 267 │   │   # Ensure credentials and universe are not in conflict.         
 268 │   │   if hasattr(self, "_credentials") and client_universe is not N  

❱ 269 │ │ │ _validate_universe(client_universe, self._credentials)
270 │ │
271 │ │ self._connection = Connection(self, **kw_args)
272 │ │ self._location = location

/home/adminuser/venv/lib/python3.12/site-packages/google/cloud/bigquery/_hel
pers.py:114 in _validate_universe

 111 │   Raises:                                                            
 112 │   │   ValueError: when client_universe does not match the universe   
 113 │   """                                                                

❱ 114 │ if hasattr(credentials, “universe_domain”):
115 │ │ cred_universe = getattr(credentials, “universe_domain”)
116 │ │ if isinstance(cred_universe, str):
117 │ │ │ if client_universe != cred_universe:

TransportError: Failed to retrieve 
http://metadata.google.internal/computeMetadata/v1/universe/universe_domain from
the Google Compute Engine metadata service. Compute Engine Metadata server 
unavailable

Check if you are able to connect to bigquery

I mean I’m logged into BigQuery in my system atleast, Have you seen anyone else work with BigQuery trying to use Streamlit Cloud as a URL?

I’m not sure how to work around this

Remove all packages from the requirements.txt that are part of Python’s standard library and run it again.

For example, remove os from your requirements.txt file.

The Python Standard Library — Python 3.13.0 documentation

This is the first error encountered, and it appears multiple times in the error log you provided. Pip is attempting to install a package that is included with Python and not listed in the PyPi registry.

I removed os but its still showing that error. But more importantly I acually have a UI layout doubt. This is my current code for a chatbot layout (inside a tab & I’ve noticed tabs have made streamlit layouts so difficult to work with):

def chat_content():
st.session_state[‘messages’].append({“role”: “user”, “content”: st.session_state[‘content’]})

with tab4:
st.title(“Feedback Insight Chat”)
if ‘messages’ not in st.session_state:
st.session_state[‘messages’] =
if ‘categories_analysis’ not in st.session_state or not st.session_state[‘categories_analysis’]:
st.write(“No feedback summaries available. Please visit the ‘Feedback Categorization’ tab first.”)

with st.container():
        for message in st.session_state['messages']:
            with st.chat_message(message["role"]):
                st.markdown(message["content"])
    with st.form("chat_form"):
        cols = st.columns((6, 1))
        cols[0].text_input(
            "Chat",
            value="",
            label_visibility="collapsed",
            key="content"
        )
        submit_button = cols[1].form_submit_button(
            "Submit", 
            type="primary", 
            on_click=chat_content
        )
    prompt = st.session_state.get('content')

with st.chat_message(“assistant”):
stream = client.chat.completions.create(
model=st.session_state[“azure_openai_model”],
messages=[
{“role”: “system”, “content”: system_message[“content”]},
{“role”: “user”, “content”: user_message[“content”]}
],
stream=True,
temperature=0.2
)
response = st.write_stream(stream)
st.session_state.messages.append({“role”: “assistant”, “content”: response})

I’ve attached a screenshot of how this looks like, I dont understand why the input form appears before the response is streamed/generated. It looks really awkward and I want the input form to be at the bottom of the page with the entire chat history above.

I used to use chat_input before but I was recommended from this post to change it when using tabs: Chat input layout adjustments

Can you help with fixing this layout?

Hi, Can you help with the UI request I posted above?

Please can you format your code in a code block so I can see your whitespace correctly? (Edit your post, highlight your code and click the < > button.)

Also, can you describe what you’re trying to do? I’m not sure what you’re saying about tabs or why you have the form and no st.chat_input

Ok @mathcatsand So what Im trying to do is just make a simple chatbot with a UI where, the input textbox is at the bottom (constantly) and the chat history/messages are displayed above . Similar to ChatGPT.

This is easy to do but the problem is I’m using st.tabs because I need multiple tabs for my site and apparently when you use tabs a lot of features dont operate the same way they work for just a normal one page streamlit site.

This is my previous code with using chat_input. Someone advised me not to use chat_input and make my own form instead if Im using tabs. Here is the code:

 with tab4:
     st.title("Feedback Insight Chat")
     
     if 'chat_history' not in st.session_state:
         st.session_state['chat_history'] = []
 
     col1, = st.columns(1)
     with col1:
         with st.container(border=True):
             if 'messages' not in st.session_state:
                 st.session_state.messages = []
 
             with st.container():
                st.chat_input(key='content', on_submit=chat_content)                  
                   button_b_pos = "3rem"
                 button_css = float_css_helper(width="2.2rem", bottom=button_b_pos, transition=0)
                 float_parent(css=button_css)
             
             for message in st.session_state.messages:
                 with st.chat_message(message["role"]):
                     st.markdown(message["content"])
             
            prompt = st.session_state.get('content')
            if prompt:
                 st.session_state.messages.append({"role": "user", "content": prompt})
                 
                 with st.chat_message("user"):
                     st.markdown(prompt)
 
                 with st.chat_message("assistant"):
                     stream = client.chat.completions.create(
                         model=st.session_state["azure_openai_model"],
                         messages=[
                             {"role": "system", "content": system_message["content"]}, 
                             {"role": "user", "content": prompt}
                         ],
                         stream=True,
                         temperature=0.2
                     )
                     response = st.write_stream(stream)
                    st.session_state.messages.append({"role": "assistant", "content": response})

But then I changed the above code and stopped using the chat_input feature and created a form like this:

 with st.form("chat_form", clear_on_submit=False):  
        user_input = st.text_input("Type your message:", key='content')
             if st.form_submit_button("Submit"):
                if user_input:
                     st.session_state['messages'].append({"role": "user", "content": user_input})

But this also hasn’t proven to do what I wanted which is just to have the input box at the bottom constantly and have the chat history go on above it. I hope the formatted code can help you understand better

Does something like this fit your needs?

import streamlit as st
import time

tabs = st.tabs(["A","B"])

def stream_reply():
    response = "Hmm, that's interesting."
    for char in response:
        yield char
        time.sleep(.05)

with tabs[0]:
    st.title("A")

with tabs[1]:
    st.title("B")
    
    if "messages" not in st.session_state:
        st.session_state["messages"] = []

    
    chat_interface = st.container(border=True)
    message_container = chat_interface.container(height=500, border=False)
    input_container = chat_interface.container()

with message_container:           
    for message in st.session_state.messages:
        with st.chat_message(message["role"]):
            st.markdown(message["content"])          
        
prompt = input_container.chat_input(key="content")
if prompt:
    st.session_state.messages.append({"role": "user", "content": prompt})
    with message_container.chat_message("user"):
        st.markdown(prompt)

    with message_container.chat_message("assistant"):
        response = st.write_stream(stream_reply())
    st.session_state.messages.append({"role": "assistant", "content": response})
1 Like

Yes!! Thank you so much, this is perfect. Is there any way to use markdown to change the background of containers and dataframes? I googled it and tried the markdown code but it doesn’t have the proper change I wanted it to.

I basically want the inverse of the colours so the backgrounds will be white but the text is navy blue/black

You can accomplish some things with CSS hacks. (Inspect elements to figure out the right classes to target and add CSS with st.html. So aside from changing some default colors through the app’s theme, that’s about it right now. We are actively working on advanced theming, though, so keep an eye out for updates.

1 Like