Work in local, but not in streamlit cloud

I am following this github repository. Get it working in local, but got error running in cloud.
https://github.com/aws-samples/amazon-kendra-langchain-extensions

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.
2023-06-15 19:04:55.635 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/app/kendralangchain/app.py", line 5, in <module>
    import kendra_chat_flan_xl as flanxl
  File "/app/kendralangchain/kendra_chat_flan_xl.py", line 1, in <module>
    from aws_langchain.kendra_index_retriever import KendraIndexRetriever
ModuleNotFoundError: No module named 'aws_langchain'


In local, I run this command to install the classes
pip install .

In cloud, it could not find the module, and I can't run cmd like "pip install aws_langchain".

What shall I do?

Hey @philipkang,

Can you share the GitHub repo for your app? You’ll need to add a requirements.txt file if you haven’t already so that the correct packages will be installed for your app.

That’s what I figured out by adding the requirements.txt file. Now the error complaining about ```
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 548, in _run_script
self._session_state.on_script_will_rerun(rerun_data.widget_states)
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/state/safe_session_state.py”, line 68, in on_script_will_rerun
self._state.on_script_will_rerun(latest_widget_states)
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/state/session_state.py”, line 482, in on_script_will_rerun
self._call_callbacks()
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/state/session_state.py”, line 495, in _call_callbacks
self._new_widget_state.call_callback(wid)
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/state/session_state.py”, line 247, in call_callback
callback(*args, **kwargs)
File “/app/kendralangchain/app.py”, line 115, in handle_input
result = chain.run_chain(llm_chain, input, chat_history)
File “/app/kendralangchain/kendra_chat_flan_xl.py”, line 71, in run_chain
return chain({“question”: prompt, “chat_history”: history})
File “/home/appuser/venv/lib/python3.9/site-packages/langchain/chains/base.py”, line 116, in call
raise e
File “/home/appuser/venv/lib/python3.9/site-packages/langchain/chains/base.py”, line 113, in call
outputs = self._call(inputs)
File “/home/appuser/venv/lib/python3.9/site-packages/langchain/chains/conversational_retrieval/base.py”, line 79, in _call
docs = self._get_docs(new_question, inputs)
File “/home/appuser/venv/lib/python3.9/site-packages/langchain/chains/conversational_retrieval/base.py”, line 146, in _get_docs
docs = self.retriever.get_relevant_documents(question)
File “/app/kendralangchain/aws_langchain/kendra_index_retriever.py”, line 44, in get_relevant_documents
docs = kendra_query(self.kclient, query, self.k, self.kendraindex)
File “/app/kendralangchain/aws_langchain/kendra_results.py”, line 23, in kendra_query
response = kclient.query(IndexId=kindex_id, QueryText=kquery.strip())
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/client.py”, line 530, in _api_call
return self._make_api_call(operation_name, kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/client.py”, line 947, in _make_api_call
http, parsed_response = self._make_request(
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/client.py”, line 970, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/endpoint.py”, line 119, in make_request
return self._send_request(request_dict, operation_model)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/endpoint.py”, line 198, in _send_request
request = self.create_request(request_dict, operation_model)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/endpoint.py”, line 134, in create_request
self._event_emitter.emit(
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/hooks.py”, line 412, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/hooks.py”, line 256, in emit
return self._emit(event_name, kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/hooks.py”, line 239, in _emit
response = handler(**kwargs)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/signers.py”, line 105, in handler
return self.sign(operation_name, request)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/signers.py”, line 189, in sign
auth.add_auth(request)
File “/home/appuser/venv/lib/python3.9/site-packages/botocore/auth.py”, line 418, in add_auth
raise NoCredentialsError()
botocore.exceptions.NoCredentialsError: Unable to locate credentials

I have set the credentials such as AWS_REGION =“us-east-1” in the Secret of Settings. Not sure why it is still complaining.

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