ModuleNotFoundError: No module named 'langchain'

run successfully locally but not in the Streamlit cloud; an error message was displayed: ModuleNotFoundError: No module named β€˜langchain’

requirements.txt:
openai
youtube-dl
chroma-js
langchain
streamlit

https://github.com/zinojeng/Chat-with-Youbue

anyone have a recommendation?

> Blockquote 
[     UTC     ] Logs for chat-with-youbue-test.streamlit.app/
────────────────────────────────────────────────────────────────────────────────────────
[14:14:46] πŸ–₯ Provisioning machine...
[14:14:46] πŸŽ› Preparing system...
[14:14:46] β›“ Spinning up manager process...
[14:14:49] πŸš€ Starting up repository: 'chat-with-youbue', branch: 'main', main module: 'frontend.py'
[14:14:49] πŸ™ Cloning repository...
[14:14:50] πŸ™ Cloning into '/mount/src/chat-with-youbue'...
[14:14:50] πŸ™ Cloned repository!
[14:14:50] πŸ™ Pulling code changes from Github...
[14:14:51] πŸ“¦ Processing dependencies...
Check if streamlit is installed
──────────────────────────────── Installing Streamlit ──────────────────────────────────
Collecting streamlit
  Downloading streamlit-1.25.0-py2.py3-none-any.whl (8.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.1/8.1 MB 100.7 MB/s eta 0:00:00[2023-08-12 14:14:52.699784] 
Collecting numpy<2,>=1.19.3
  Downloading numpy-1.25.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.3/18.3 MB 244.9 MB/s eta 0:00:00[2023-08-12 14:14:53.249416] 
Collecting rich<14,>=10.14.0
  Downloading rich-13.5.2-py3-none-any.whl (239 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 239.7/239.7 KB 231.0 MB/s eta 0:00:00[2023-08-12 14:14:53.414307] 
Collecting packaging<24,>=16.8
  Downloading packaging-23.1-py3-none-any.whl (48 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 KB 119.6 MB/s eta 0:00:00[2023-08-12 14:14:53.472832] 
Collecting click<9,>=7.0
  Downloading click-8.1.6-py3-none-any.whl (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 KB 119.5 MB/s eta 0:00:00[2023-08-12 14:14:53.556219] 
Collecting cachetools<6,>=4.0
  Downloading cachetools-5.3.1-py3-none-any.whl (9.3 kB)
Collecting blinker<2,>=1.0.0
  Downloading blinker-1.6.2-py3-none-any.whl (13 kB)
Collecting protobuf<5,>=3.20
  Downloading protobuf-4.24.0-cp37-abi3-manylinux2014_x86_64.whl (311 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 311.6/311.6 KB 184.8 MB/s eta 0:00:00[2023-08-12 14:14:54.063703] 
Collecting watchdog>=2.1.5
  Downloading watchdog-3.0.0-py3-none-manylinux2014_x86_64.whl (82 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.1/82.1 KB 158.0 MB/s eta 0:00:00[2023-08-12 14:14:54.257358] 
Collecting python-dateutil<3,>=2.7.3
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 KB 126.7 MB/s eta 0:00:00
Collecting tenacity<9,>=8.1.0
  Downloading tenacity-8.2.2-py3-none-any.whl (24 kB)
Collecting pillow<10,>=7.1.0
  Downloading Pillow-9.5.0-cp39-cp39-manylinux_2_28_x86_64.whl (3.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 257.7 MB/s eta 0:00:00[2023-08-12 14:14:54.884084] 
Collecting tzlocal<5,>=1.1
  Downloading tzlocal-4.3.1-py3-none-any.whl (20 kB)
Collecting pyarrow>=6.0
  Downloading pyarrow-12.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (39.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 39.0/39.0 MB 252.0 MB/s eta 0:00:00[2023-08-12 14:14:55.284258] 
Collecting gitpython!=3.1.19,<4,>=3.0.7
  Downloading GitPython-3.1.32-py3-none-any.whl (188 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 188.5/188.5 KB 223.2 MB/s eta 0:00:00[2023-08-12 14:14:55.406045] 
Collecting toml<2,>=0.10.1
  Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting validators<1,>=0.2
  Downloading validators-0.21.2-py3-none-any.whl (25 kB)
Collecting pandas<3,>=1.3.0
  Downloading pandas-2.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.4/12.4 MB 242.3 MB/s eta 0:00:00[2023-08-12 14:14:55.826525] 
Collecting typing-extensions<5,>=4.1.0
  Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Collecting altair<6,>=4.0
  Downloading altair-5.0.1-py3-none-any.whl (471 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 471.5/471.5 KB 170.9 MB/s eta 0:00:00[2023-08-12 14:14:55.966459] 
Collecting tornado<7,>=6.0.3
  Downloading tornado-6.3.3-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (427 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 427.7/427.7 KB 143.4 MB/s eta 0:00:00[2023-08-12 14:14:56.126861] 
Collecting importlib-metadata<7,>=1.4
  Downloading importlib_metadata-6.8.0-py3-none-any.whl (22 kB)
Collecting pydeck<1,>=0.8
  Downloading pydeck-0.8.0-py2.py3-none-any.whl (4.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.7/4.7 MB 147.1 MB/s eta 0:00:00[2023-08-12 14:14:56.383653] 
Collecting requests<3,>=2.18
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 KB 120.9 MB/s eta 0:00:00[2023-08-12 14:14:56.515050] 
Collecting pympler<2,>=0.9
  Downloading Pympler-1.0.1-py3-none-any.whl (164 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 164.8/164.8 KB 185.0 MB/s eta 0:00:00[2023-08-12 14:14:56.566054] 
Collecting toolz
  Downloading toolz-0.12.0-py3-none-any.whl (55 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 55.8/55.8 KB 128.9 MB/s eta 0:00:00[2023-08-12 14:14:56.676030] 
Collecting jinja2
  Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 KB 136.8 MB/s eta 0:00:00[2023-08-12 14:14:56.786646] 
Collecting jsonschema>=3.0
  Downloading jsonschema-4.19.0-py3-none-any.whl (83 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.4/83.4 KB 121.1 MB/s eta 0:00:00[2023-08-12 14:14:56.889964] 
Collecting gitdb<5,>=4.0.1
  Downloading gitdb-4.0.10-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.7/62.7 KB 146.8 MB/s eta 0:00:00[2023-08-12 14:14:56.956911] 
Collecting zipp>=0.5
  Downloading zipp-3.16.2-py3-none-any.whl (7.2 kB)
Collecting tzdata>=2022.1
  Downloading tzdata-2023.3-py2.py3-none-any.whl (341 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 341.8/341.8 KB 162.4 MB/s eta 0:00:00[2023-08-12 14:14:57.241847] 
Collecting pytz>=2020.1
  Downloading pytz-2023.3-py2.py3-none-any.whl (502 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 502.3/502.3 KB 133.5 MB/s eta 0:00:00[2023-08-12 14:14:57.380192] 
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting urllib3<3,>=1.21.1
  Downloading urllib3-2.0.4-py3-none-any.whl (123 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.9/123.9 KB 207.9 MB/s eta 0:00:00[2023-08-12 14:14:57.695876] 
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (202 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 202.1/202.1 KB 221.6 MB/s eta 0:00:00[2023-08-12 14:14:57.837646] 
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 KB 123.6 MB/s eta 0:00:00[2023-08-12 14:14:57.884695] 
Collecting certifi>=2017.4.17
  Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 KB 147.6 MB/s eta 0:00:00[2023-08-12 14:14:57.942720] 
Collecting markdown-it-py>=2.2.0
  Downloading markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.5/87.5 KB 156.8 MB/s eta 0:00:00[2023-08-12 14:14:58.028228] 
Collecting pygments<3.0.0,>=2.13.0
  Downloading Pygments-2.16.1-py3-none-any.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 296.7 MB/s eta 0:00:00[2023-08-12 14:14:58.099206] 
Collecting pytz-deprecation-shim
  Downloading pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB)
Collecting smmap<6,>=3.0.1
  Downloading smmap-5.0.0-py3-none-any.whl (24 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting jsonschema-specifications>=2023.03.6
  Downloading jsonschema_specifications-2023.7.1-py3-none-any.whl (17 kB)
Collecting rpds-py>=0.7.1
  Downloading rpds_py-0.9.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 213.8 MB/s eta 0:00:00[2023-08-12 14:14:58.803222] 
Collecting referencing>=0.28.4
  Downloading referencing-0.30.2-py3-none-any.whl (25 kB)
Collecting attrs>=22.2.0
  Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 KB 144.4 MB/s eta 0:00:00[2023-08-12 14:14:58.934465] 
Collecting mdurl~=0.1
  Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Installing collected packages: pytz, zipp, watchdog, validators, urllib3, tzdata, typing-extensions, tornado, toolz, toml, tenacity, smmap, six, rpds-py, pympler, pygments, protobuf, pillow, packaging, numpy, mdurl, MarkupSafe, idna, click, charset-normalizer, certifi, cachetools, blinker, attrs, requests, referencing, pytz-deprecation-shim, python-dateutil, pyarrow, markdown-it-py, jinja2, importlib-metadata, gitdb, tzlocal, rich, pydeck, pandas, jsonschema-specifications, gitpython, jsonschema, altair, streamlit
Successfully installed MarkupSafe-2.1.3 altair-5.0.1 attrs-23.1.0 blinker-1.6.2 cachetools-5.3.1 certifi-2023.7.22 charset-normalizer-3.2.0 click-8.1.6 gitdb-4.0.10 gitpython-3.1.32 idna-3.4 importlib-metadata-6.8.0 jinja2-3.1.2 jsonschema-4.19.0 jsonschema-specifications-2023.7.1 markdown-it-py-3.0.0 mdurl-0.1.2 numpy-1.25.2 packaging-23.1 pandas-2.0.3 pillow-9.5.0 protobuf-4.24.0 pyarrow-12.0.1 pydeck-0.8.0 pygments-2.16.1 pympler-1.0.1 python-dateutil-2.8.2 pytz-2023.3 pytz-deprecation-shim-0.1.0.post0 referencing-0.30.2 requests-2.31.0 rich-13.5.2 rpds-py-0.9.2 six-1.16.0 smmap-5.0.0 streamlit-1.25.0 tenacity-8.2.2 toml-0.10.2 toolz-0.12.0 tornado-6.3.3 typing-extensions-4.7.1 tzdata-2023.3 tzlocal-4.3.1 urllib3-2.0.4 validators-0.21.2 watchdog-3.0.0 zipp-3.16.2
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.
────────────────────────────────────────────────────────────────────────────────────────
[14:15:13] πŸ“¦ Processed dependencies!
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.
2023-08-12 14:15:56.015 Uncaught app exception
Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/chat-with-youbue/frontend.py", line 2, in <module>
    from backend import comp_press
  File "/mount/src/chat-with-youbue/backend.py", line 2, in <module>
    from langchain.llms import OpenAI
ModuleNotFoundError: No module named 'langchain'

Try rebooting the app. If issue still persists include tiktoken also in ur requirements file

not work. When deployed on Streamlit Cloud, I believe there is still a bug with the import module.

Try including this in requirements β€˜langchain[all]’

Hey @zinojeng I got the solution for this :smiling_face_with_tear::smiling_face_with_tear::smiling_face_with_tear:…
It is just a simple mistake …

:point_right:t2: All you have to do is to correct the name of the file as requirements.txt

because streamlit is not auto recognizing it as currently, the name of the file is reqirements.txt

Happy Coding :smiling_face:
Thanks for posting.

2 Likes

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