Deploy Streamlit app in Streamlit Community Cloud

I have tried to deploy a streamlit app on Streamlit Community Cloud. I followed the instructions given here. But as I write code in GitHub Codespace, the new written codes are not saved to the git repository, even after save it. Also, when I open my streamlit app link from my Streamlit Community Cloud, I found it opens a welcome page instead of my streamlit app.

1 Like

Hi! From the color highlighting, it looks like you did not commit and push your changes from your codespace to your Git repository. This article might be of use Using source control in your codespace - GitHub Docs .

If that doesn’t work, we can jump on a call and go through the process together. Maybe we can find ways to improve editing in codespaces :slight_smile:

1 Like

@Alexandru_Toader

I tried to commit the changes by click the Source Control view and then click Commit .

But after an hours it shows Codespace Stopped

1 Like

Could you enter a commit message in the top left and then press the commit button? The commit is still not complete

1 Like

@Alexandru_Toader

When I open my application URL, it shows this message

[     UTC     ] Logs for stock-trend-6fkgvep7emn.streamlit.app/

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

[13:53:48] πŸš€ Starting up repository: 'stock-trend', branch: 'main', main module: 'Hello.py'

[13:53:48] πŸ™ Cloning repository...

[13:53:49] πŸ™ Cloning into '/mount/src/stock-trend'...
Warning: Permanently added the ED25519 host key for IP address '140.82.116.4' to the list of known hosts.

[13:53:49] πŸ™ Cloned repository!

[13:53:49] πŸ™ Pulling code changes from Github...

[13:53:50] πŸ“¦ Processing dependencies...


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


Using standard pip install.

Collecting argon2-cffi==23.1.0 (from -r /mount/src/stock-trend/requirements.txt (line 1))

  Downloading argon2_cffi-23.1.0-py3-none-any.whl.metadata (5.2 kB)

Collecting ipython==8.23.0 (from -r /mount/src/stock-trend/requirements.txt (line 2))

  Downloading ipython-8.23.0-py3-none-any.whl.metadata (4.9 kB)

Collecting keras==3.1.1 (from -r /mount/src/stock-trend/requirements.txt (line 3))

  Downloading keras-3.1.1-py3-none-any.whl.metadata (5.6 kB)

Collecting matplotlib==3.8.3 (from -r /mount/src/stock-trend/requirements.txt (line 4))

  Downloading matplotlib-3.8.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.8 kB)

Collecting neuralprophet==0.8.0 (from -r /mount/src/stock-trend/requirements.txt (line 5))

  Downloading neuralprophet-0.8.0-py3-none-any.whl.metadata (9.1 kB)

Collecting numpy==1.26.4 (from -r /mount/src/stock-trend/requirements.txt (line 6))

  Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)

     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 5.9 MB/s eta 0:00:00[2024-04-16 13:53:52.001661] 

Collecting pandas==2.2.1 (from -r /mount/src/stock-trend/requirements.txt (line 7))

  Downloading pandas-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)

Collecting password-strength==0.0.3.post2 (from -r /mount/src/stock-trend/requirements.txt (line 8))

  Downloading password_strength-0.0.3.post2-py2.py3-none-any.whl.metadata (10 kB)

Collecting requests==2.31.0 (from -r /mount/src/stock-trend/requirements.txt (line 9))

  Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)

Collecting scikit-learn==1.4.1.post1 (from -r /mount/src/stock-trend/requirements.txt (line 10))

  Downloading scikit_learn-1.4.1.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)

Collecting scipy==1.13.0 (from -r /mount/src/stock-trend/requirements.txt (line 11))

  Downloading scipy-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)

     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.6/60.6 kB 264.1 MB/s eta 0:00:00[2024-04-16 13:53:52.499509] 

Collecting psycopg2==2.9.9 (from -r /mount/src/stock-trend/requirements.txt (line 12))

  Downloading psycopg2-2.9.9.tar.gz (384 kB)

     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 384.9/384.9 kB 37.2 MB/s eta 0:00:00[2024-04-16 13:53:52.587100] 

  Preparing metadata (setup.py): started

  Preparing metadata (setup.py): finished with status 'error'

  error: subprocess-exited-with-error

  

  Γ— python setup.py egg_info did not run successfully.

  β”‚ exit code: 1

  ╰─> [23 lines of output]

      running egg_info

      creating /tmp/pip-pip-egg-info-m7mi7u82/psycopg2.egg-info

      writing /tmp/pip-pip-egg-info-m7mi7u82/psycopg2.egg-info/PKG-INFO

      writing dependency_links to /tmp/pip-pip-egg-info-m7mi7u82/psycopg2.egg-info/dependency_links.txt

      writing top-level names to /tmp/pip-pip-egg-info-m7mi7u82/psycopg2.egg-info/top_level.txt

      writing manifest file '/tmp/pip-pip-egg-info-m7mi7u82/psycopg2.egg-info/SOURCES.txt'

      

      Error: pg_config executable not found.

      

      pg_config is required to build psycopg2 from source.  Please add the directory

      containing pg_config to the $PATH or specify the full executable path with the

      option:

      

          python setup.py build_ext --pg-config /path/to/pg_config build ...

      

      or with the pg_config option in 'setup.cfg'.

      

      If you prefer to avoid building psycopg2 from source, please install the PyPI

      'psycopg2-binary' package instead.

      

      For further information please check the 'doc/src/install.rst' file (also at

      <https://www.psycopg.org/docs/install.html>).

      

      [end of output]

  

  note: This error originates from a subprocess, and is likely not a problem with pip.

error: metadata-generation-failed


Γ— Encountered error while generating package metadata.

╰─> See above for output.


note: This is an issue with the package mentioned above, not pip.

hint: See above for details.

Checking if Streamlit is installed


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


[13:53:54] ❗️ installer returned a non-zero exit code

[13:53:54] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.

[13:55:28] ❗️ Streamlit server consistently failed status checks

[13:55:28] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.

main
sanniddha/stock-trend/main/Hello.py
1 Like

Hey @Sanniddha ! This appears to be an issue with one of your dependencies. Can you share access to your source code? If not, can you create a smaller application that reproduces the issue?

@Alexandru_Toader

This is my code repo

Ignore Fly.toml and Dockers files.

Thank you! We’ll look into it and see if this is an issue on our side.

Hi @Sanniddha, this is a know issue with psycopg2. You have two options:

  • Install psycopg2-binary instead of psycopg2 - simple, fast and recommended - which is a binary distribution
  • Install the libraries and sources required by psycopg2 - a bit harder - you can do so using APT

More on the topic: Installation β€” Psycopg 2.9.9 documentation

1 Like

@Alexandru_Toader @Antoni_Kedracki
psycopg2-binary works fine. But now I am getting another error: Importing plotly failed. Interactive plots will not work. after logging to the app.

[     UTC     ] Logs for stocktrend-hewy7dc3fhsiby29dn8e29.streamlit.app/

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

[17:01:10] πŸ–₯ Provisioning machine...

[17:01:10] πŸŽ› Preparing system...

[17:01:10] β›“ Spinning up manager process...

[16:49:48] πŸš€ Starting up repository: 'stock_trend', branch: 'master', main module: 'index.py'

[16:49:48] πŸ™ Cloning repository...

[16:49:49] πŸ™ Cloning into '/mount/src/stock_trend'...
Warning: Permanently added the ED25519 host key for IP address '140.82.116.3' to the list of known hosts.

[16:49:49] πŸ™ Cloned repository!

[16:49:49] πŸ™ Pulling code changes from Github...

[16:49:50] πŸ“¦ Processing dependencies...


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


Using uv pip install.

Resolved 150 packages in 1.84s

Downloaded 148 packages in 49.01s

Installed 148 packages in 1.59s

 + absl-py==2.1.0

 + aiohttp==3.9.5

 + aiosignal==1.3.1

 + altair==5.3.0

 + appdirs==1.4.4

 + argon2-cffi==23.1.0

 + argon2-cffi-bindings==21.2.0

 + asttokens==2.4.1

 + astunparse==1.6.3

 + attrs==23.2.0

 + beautifulsoup4==4.12.3

 + blinker==1.8.1

 + cachetools==5.3.3

 + captum==0.7.0

 + certifi==2024.2.2

 + cffi==1.16.0

 + charset-normalizer==3.3.2

 + click==8.1.7

 + colorama==0.4.6

 + contourpy==1.2.1

 + cycler==0.12.1

 + decorator==5.1.1

 + executing==2.0.1

 + fastjsonschema==2.19.1

 + filelock==3.14.0

 + flatbuffers==24.3.25

 + fonttools==4.51.0

 + frozendict==2.4.3

 + frozenlist==1.4.1

 + fsspec==2024.3.1

 + gast==0.5.4

 [2024-05-06 16:50:43.424106] + gitdb==4.0.11

 + gitpython==3.1.43

 + google-pasta==0.2.0

 + greenlet==3.0.3

 + grpcio==1.63.0

 + h5py==3.11.0

 + holidays==0.48

 + html5lib==1.1

 + idna==3.7

 + ipython==8.24.0

 + jedi==0.19.1

 + jinja2==3.1.4

 + joblib==1.4.2

 + jsonschema==4.22.0

 + jsonschema-specifications==2023.12.1

 + jupyter-core==5.7.2

 + keras==3.3.3

 + kiwisolver==1.4.5

 + libclang==18.1.1

 + lightning-utilities==0.11.2

 + lxml==5.2.1

 + markdown==3.6

 + markdown-it-py==3.0.0

 + markupsafe==2.1.5

 + matplotlib==3.8.4

 + matplotlib-inline==0.1.7

 +[2024-05-06 16:50:43.424309]  mdurl==0.1.2

 + ml-dtypes==0.3.2

 + mpmath==1.3.0

 + multidict==6.0.5

 + multitasking==0.0.11

 + namex==0.0.8

 + nbformat==5.10.4

 + networkx==3.3

 [2024-05-06 16:50:43.424572] + neuralprophet==0.8.0

 + numpy==1.26.4

 + nvidia-cublas-cu12==12.1.3.1

 + nvidia-cuda-cupti-cu12==12.1.105

 + [2024-05-06 16:50:43.424746] nvidia-cuda-nvrtc-cu12==12.1.105

 + nvidia-cuda-runtime-cu12==12.1.105

 + nvidia-cudnn-cu12==8.9.2.26

 + nvidia-cufft-cu12==11.0.2.54

 + nvidia-curand-cu12==10.3.2.106

 + nvidia-cusolver-cu12==11.4.5.107

 + nvidia-cusparse-cu12==12.1.0.106

 + nvidia-nccl-cu12==2.20.5

 + nvidia-nvjitlink-cu12==12.4.127

 + nvidia-nvtx-cu12==12.1.105

 + opt-einsum==3.3.0

 + optree==0.11.0

 + packaging==24.0

 + pandas==2.2.2

 + parso[2024-05-06 16:50:43.425509] ==0.8.4

 + password-strength==0.0.3.post2

 + peewee==3.17.3

 + pexpect==4.9.0

 + pillow==10.3.0

 + platformdirs==4.2.1

 + plotly==5.22.0

 + pretty-errors==1.2.25

 + prompt-toolkit==3.0.43

 + protobuf==4.25.3

 + psycopg2-binary==2.9.9

 + ptyprocess==0.7.0

 + pure-eval==0.2.2

 + pyarrow==16.0.0

 + pycparser==2.22

 + pydeck==0.9.0

 + pygments==2.18.0

 + pyparsing==3.1.2

 + python-dateutil==2.9.0.post0

 + python-decouple==3.8

 + pytorch-lightning==1.9.5

 + pytz==2024.1

 [2024-05-06 16:50:43.426231] + pyyaml==6.0.1

 + referencing==0.35.1

 + requests==2.31.0

 + rich==13.7.1

 + rpds-py==0.18.1

 + scikit-learn==1.4.2

 + scipy==1.13.0

 + secure-smtplib==0.1.1

 + six==1.16.0

 + smmap==5.0.1

 + smtpemail==0.4.2

 + soupsieve==2.5

 + sqlalchemy==2.0.30

 + sqlalchemy-utils==0.41.2

 + stack-data==0.6.3

 + streamlit==1.34.0

 + [2024-05-06 16:50:43.426386] streamlit-option-menu==0.3.12

 + sympy==1.12

 + tenacity==8.2.3

 + tensorboard==2.16.2

 + tensorboard-data-server==0.7.2

 + tensorflow==2.16.1

 + [2024-05-06 16:50:43.426557] tensorflow-io-gcs-filesystem==0.37.0

 + termcolor==2.4.0

 + threadpoolctl==3.5.0

 + toml==0.10.2

 +[2024-05-06 16:50:43.426675]  toolz==0.12.1

 + torch==2.3.0

 + torchmetrics==1.4.0

 + tornado==6.4

 + tqdm==4.66.4

 +[2024-05-06 16:50:43.426825]  traitlets==5.14.3

 + triton==2.3.0

 + typing-extensions==4.11.0

 + tzdata==2024.1

 + urllib3==2.2.1

 + watchdog==4.0.0

 [2024-05-06 16:50:43.426940] + wcwidth==0.2.13

 + webencodings==0.5.1

 + werkzeug==3.0.3

 + wrapt==1.16.0

 +[2024-05-06 16:50:43.427068]  yarl==1.9.4

 + yfinance==0.2.38

Checking if Streamlit is installed

Found Streamlit version 1.34.0 in the environment


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


[16:50:45] 🐍 Python dependencies were installed from /mount/src/stock_trend/requirements.txt using uv.

Check if streamlit is installed

Streamlit is already installed

[16:50:47] πŸ“¦ Processed dependencies!




Importing plotly failed. Interactive plots will not work.

Importing plotly failed. Interactive plots will not work.

I have upgrade the plotly using pip install --upgrade plotly, but getting the same error after logged in.

Here is my app link: https://stock-cast.streamlit.app/

You can use my test credentials to login:
Email: sanniddhachakrabarti@gmail.com
Password: Streamlit@1947

Here is my code repo:

I am getting this error when I am visiting this page:

Could you try following the instructions in this GitHub post Importing plotly failed. Interactive plots will not work Β· Issue #2387 Β· facebook/prophet Β· GitHub? Is your app affected by that error?

Yes I am getting this error. As per this Git link, this error is resolved by pip install plotly, but in my case it is not resolved by this pip command

I had a look at the source code of GitHub - ourownstory/neural_prophet: NeuralProphet: A simple forecasting package an found the place this is error message is logged:

try:
    from plotly_resampler import register_plotly_resampler, unregister_plotly_resampler

    plotly_resampler_installed = True
except ImportError:
    plotly_resampler_installed = False
    log.error("Importing plotly failed. Interactive plots will not work.")

So it seams it is actually trying to import plotly_resampler which is a optional dependency. Please add plotly_resampler to your dependency list and have a try.

1 Like

@Antoni_Kedracki
Thanks a lot. It works

Now, I want to hide the side navigation. --client.showSidebarNavigation false command hide the side navigation.

When I open the app URL, it runs streamlit run index.py --server.enableCORS false --server.enableXsrfProtection false command.
So, how can I include this command in streamlit run command, I means, I want to run this command streamlit run index.py --server.enableCORS false --server.enableXsrfProtection false --client.showSidebarNavigation false.

I don’t think you can. Use a configuration file instead.

1 Like

@Goyo
How to define this config.toml.
Just write showSidebarNavigation = False, right?

You can just include the options you care about and ignore everything else. There is an example at the top.

Remember to reboot the app after you change the configuration or the requirements.

1 Like

@Goyo
It works fine if I open the app from Github codespace. But, when reboot the app and open the app, the sidebar navigation is still there.

I can’t find a configuration file in your repository.

this config.toml file was hidden by .gitignore since ./streamlit was there in .gitignore.
I have now modify .gitignore to .streamlit/secrets.toml to hide the secrets.toml only and now it works fine.

Thank you for your help