{"id":12644,"date":"2025-01-19T14:53:33","date_gmt":"2025-01-19T14:53:33","guid":{"rendered":"https:\/\/myprojects.advchaweb.com\/?p=12644"},"modified":"2025-01-20T04:00:54","modified_gmt":"2025-01-20T04:00:54","slug":"python-and-streamlit-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2025\/01\/19\/python-and-streamlit-on-ubuntu-22-04\/","title":{"rendered":"Python and Streamlit on Ubuntu 22.04"},"content":{"rendered":"<p>Check the installed python<\/p>\n<p>satria@teddy:~$ pip -V<br \/>\npip 22.0.2 from \/usr\/lib\/python3\/dist-packages\/pip (python 3.10)<\/p>\n<p>it seems I already installed python 3. but when I want to find out the location with &#8216;whereis python&#8217;, it showed up nothing<\/p>\n<p>satria@teddy:~$ whereis python<br \/>\npython:<\/p>\n<p>so use &#8216;whereis python3&#8217; instead<\/p>\n<p>satria@teddy:~$ whereis python3<br \/>\npython3: \/usr\/bin\/python3 \/usr\/lib\/python3 \/etc\/python3 \/usr\/share\/python3 \/usr\/share\/man\/man1\/python3.1.gz<\/p>\n<p>I need to symlink python 3 to use just &#8216;python&#8217; like this<br \/>\nsatria@teddy:~$ sudo ln -s \/usr\/bin\/python3 \/usr\/bin\/python<\/p>\n<p>then I can use like this<br \/>\nsatria@teddy:~$ whereis python<br \/>\npython: \/usr\/bin\/python<\/p>\n<p>Install streamlit with python3 virtual environment (venv)<br \/>\nref: https:\/\/docs.streamlit.io\/get-started\/installation\/command-line<\/p>\n<p>create a new directory.\u00a0 for\u00a0 example &#8216;streamlit&#8217;<br \/>\nsatria@teddy:~$ cd Documents\/projects\/python\/streamlit\/<\/p>\n<p>then go into the dir. make sure you already have python3-venv package. if not install it<br \/>\nsatria@teddy:~\/Documents\/projects\/python\/streamlit$ sudo apt install python3.10-venv<\/p>\n<p>then use python3-venv like this:<br \/>\nsatria@teddy:~\/Documents\/projects\/python\/streamlit$ python -m venv .venv<\/p>\n<p>Activate the virtual environment<br \/>\nsatria@teddy:~\/Documents\/projects\/python\/streamlit$ source .venv\/bin\/activate<br \/>\n(.venv) satria@teddy:~\/Documents\/projects\/python\/streamlit$<\/p>\n<p>install streamlit with pip in the venv<br \/>\n(.venv) satria@teddy:~\/Documents\/projects\/python\/streamlit$ pip install streamlit<br \/>\nCollecting streamlit<br \/>\nUsing cached streamlit-1.41.1-py2.py3-none-any.whl (9.1 MB)<br \/>\nCollecting click&lt;9,&gt;=7.0<br \/>\nDownloading click-8.1.8-py3-none-any.whl (98 kB)<br \/>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 98.2\/98.2 KB 915.4 kB\/s eta 0:00:00<br \/>\nCollecting tornado&lt;7,&gt;=6.0.3<br \/>\nUsing cached tornado-6.4.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (437 kB)<br \/>\nCollecting packaging&lt;25,&gt;=20<br \/>\nUsing cached packaging-24.2-py3-none-any.whl (65 kB)<br \/>\nCollecting requests&lt;3,&gt;=2.27<br \/>\nUsing cached requests-2.32.3-py3-none-any.whl (64 kB)<br \/>\nCollecting pydeck&lt;1,&gt;=0.8.0b4<br \/>\nUsing cached pydeck-0.9.1-py2.py3-none-any.whl (6.9 MB)<br \/>\nCollecting numpy&lt;3,&gt;=1.23<br \/>\nUsing cached numpy-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.4 MB)<br \/>\nCollecting gitpython!=3.1.19,&lt;4,&gt;=3.0.7<br \/>\nUsing cached GitPython-3.1.44-py3-none-any.whl (207 kB)<br \/>\nCollecting toml&lt;2,&gt;=0.10.1<br \/>\nUsing cached toml-0.10.2-py2.py3-none-any.whl (16 kB)<br \/>\nCollecting cachetools&lt;6,&gt;=4.0<br \/>\nUsing cached cachetools-5.5.0-py3-none-any.whl (9.5 kB)<br \/>\nCollecting pandas&lt;3,&gt;=1.4.0<br \/>\nUsing cached pandas-2.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB)<br \/>\nCollecting blinker&lt;2,&gt;=1.0.0<br \/>\nDownloading blinker-1.9.0-py3-none-any.whl (8.5 kB)<br \/>\nCollecting altair&lt;6,&gt;=4.0<br \/>\nUsing cached altair-5.5.0-py3-none-any.whl (731 kB)<br \/>\nCollecting watchdog&lt;7,&gt;=2.1.5<br \/>\nUsing cached watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl (79 kB)<br \/>\nCollecting pyarrow&gt;=7.0<br \/>\nUsing cached pyarrow-19.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (42.1 MB)<br \/>\nCollecting typing-extensions&lt;5,&gt;=4.3.0<br \/>\nUsing cached typing_extensions-4.12.2-py3-none-any.whl (37 kB)<br \/>\nCollecting pillow&lt;12,&gt;=7.1.0<br \/>\nDownloading pillow-11.1.0-cp310-cp310-manylinux_2_28_x86_64.whl (4.5 MB)<br \/>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 4.5\/4.5 MB 14.1 MB\/s eta 0:00:00<br \/>\nCollecting protobuf&lt;6,&gt;=3.20<br \/>\nUsing cached protobuf-5.29.3-cp38-abi3-manylinux2014_x86_64.whl (319 kB)<br \/>\nCollecting rich&lt;14,&gt;=10.14.0<br \/>\nUsing cached rich-13.9.4-py3-none-any.whl (242 kB)<br \/>\nCollecting tenacity&lt;10,&gt;=8.1.0<br \/>\nUsing cached tenacity-9.0.0-py3-none-any.whl (28 kB)<br \/>\nCollecting jsonschema&gt;=3.0<br \/>\nUsing cached jsonschema-4.23.0-py3-none-any.whl (88 kB)<br \/>\nCollecting narwhals&gt;=1.14.2<br \/>\nUsing cached narwhals-1.22.0-py3-none-any.whl (297 kB)<br \/>\nCollecting jinja2<br \/>\nUsing cached jinja2-3.1.5-py3-none-any.whl (134 kB)<br \/>\nCollecting gitdb&lt;5,&gt;=4.0.1<br \/>\nUsing cached gitdb-4.0.12-py3-none-any.whl (62 kB)<br \/>\nCollecting pytz&gt;=2020.1<br \/>\nDownloading pytz-2024.2-py2.py3-none-any.whl (508 kB)<br \/>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 508.0\/508.0 KB 5.5 MB\/s eta 0:00:00<br \/>\nCollecting tzdata&gt;=2022.7<br \/>\nUsing cached tzdata-2024.2-py2.py3-none-any.whl (346 kB)<br \/>\nCollecting python-dateutil&gt;=2.8.2<br \/>\nUsing cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)<br \/>\nCollecting certifi&gt;=2017.4.17<br \/>\nDownloading certifi-2024.12.14-py3-none-any.whl (164 kB)<br \/>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 164.9\/164.9 KB 12.2 MB\/s eta 0:00:00<br \/>\nCollecting urllib3&lt;3,&gt;=1.21.1<br \/>\nDownloading urllib3-2.3.0-py3-none-any.whl (128 kB)<br \/>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 128.4\/128.4 KB 12.5 MB\/s eta 0:00:00<br \/>\nCollecting idna&lt;4,&gt;=2.5<br \/>\nDownloading idna-3.10-py3-none-any.whl (70 kB)<br \/>\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 70.4\/70.4 KB 14.6 MB\/s eta 0:00:00<br \/>\nCollecting charset-normalizer&lt;4,&gt;=2<br \/>\nUsing cached charset_normalizer-3.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (146 kB)<br \/>\nCollecting pygments&lt;3.0.0,&gt;=2.13.0<br \/>\nUsing cached pygments-2.19.1-py3-none-any.whl (1.2 MB)<br \/>\nCollecting markdown-it-py&gt;=2.2.0<br \/>\nUsing cached markdown_it_py-3.0.0-py3-none-any.whl (87 kB)<br \/>\nCollecting smmap&lt;6,&gt;=3.0.1<br \/>\nUsing cached smmap-5.0.2-py3-none-any.whl (24 kB)<br \/>\nCollecting MarkupSafe&gt;=2.0<br \/>\nDownloading MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (20 kB)<br \/>\nCollecting referencing&gt;=0.28.4<br \/>\nUsing cached referencing-0.36.1-py3-none-any.whl (26 kB)<br \/>\nCollecting jsonschema-specifications&gt;=2023.03.6<br \/>\nUsing cached jsonschema_specifications-2024.10.1-py3-none-any.whl (18 kB)<br \/>\nCollecting rpds-py&gt;=0.7.1<br \/>\nUsing cached rpds_py-0.22.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (381 kB)<br \/>\nCollecting attrs&gt;=22.2.0<br \/>\nUsing cached attrs-24.3.0-py3-none-any.whl (63 kB)<br \/>\nCollecting mdurl~=0.1<br \/>\nUsing cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)<br \/>\nCollecting six&gt;=1.5<br \/>\nDownloading six-1.17.0-py2.py3-none-any.whl (11 kB)<br \/>\nInstalling collected packages: pytz, watchdog, urllib3, tzdata, typing-extensions, tornado, toml, tenacity, smmap, six, rpds-py, pygments, pyarrow, protobuf, pillow, packaging, numpy, narwhals, mdurl, MarkupSafe, idna, click, charset-normalizer, certifi, cachetools, blinker, attrs, requests, referencing, python-dateutil, markdown-it-py, jinja2, gitdb, rich, pydeck, pandas, jsonschema-specifications, gitpython, jsonschema, altair, streamlit<br \/>\nSuccessfully installed MarkupSafe-3.0.2 altair-5.5.0 attrs-24.3.0 blinker-1.9.0 cachetools-5.5.0 certifi-2024.12.14 charset-normalizer-3.4.1 click-8.1.8 gitdb-4.0.12 gitpython-3.1.44 idna-3.10 jinja2-3.1.5 jsonschema-4.23.0 jsonschema-specifications-2024.10.1 markdown-it-py-3.0.0 mdurl-0.1.2 narwhals-1.22.0 numpy-2.2.2 packaging-24.2 pandas-2.2.3 pillow-11.1.0 protobuf-5.29.3 pyarrow-19.0.0 pydeck-0.9.1 pygments-2.19.1 python-dateutil-2.9.0.post0 pytz-2024.2 referencing-0.36.1 requests-2.32.3 rich-13.9.4 rpds-py-0.22.3 six-1.17.0 smmap-5.0.2 streamlit-1.41.1 tenacity-9.0.0 toml-0.10.2 tornado-6.4.2 typing-extensions-4.12.2 tzdata-2024.2 urllib3-2.3.0 watchdog-6.0.0<\/p>\n<p>test it by typing &#8216;streamlit hello&#8217;<\/p>\n<p>(.venv) satria@teddy:~\/Documents\/projects\/python\/streamlit$ streamlit hello<\/p>\n<p>\ud83d\udc4b Welcome to Streamlit!<\/p>\n<p>If you\u2019d like to receive helpful onboarding emails, news, offers, promotions,<br \/>\nand the occasional swag, please enter your email address below. Otherwise,<br \/>\nleave this field blank.<\/p>\n<p>Email: your_email@yahoo.com<\/p>\n<p>You can find our privacy policy at https:\/\/streamlit.io\/privacy-policy<\/p>\n<p>Summary:<br \/>\n&#8211; This open source library collects usage statistics.<br \/>\n&#8211; We cannot see and do not store information contained inside Streamlit apps,<br \/>\nsuch as text, charts, images, etc.<br \/>\n&#8211; Telemetry data is stored in servers in the United States.<br \/>\n&#8211; If you&#8217;d like to opt out, add the following to ~\/.streamlit\/config.toml,<br \/>\ncreating that file if necessary:<\/p>\n<p>[browser]<br \/>\ngatherUsageStats = false<\/p>\n<p>Welcome to Streamlit. Check out our demo in your browser.<\/p>\n<p>Local URL: http:\/\/localhost:8501<br \/>\nNetwork URL: http:\/\/192.168.1.23:8501<\/p>\n<p>Ready to create your own Python apps super quickly?<br \/>\nHead over to https:\/\/docs.streamlit.io<\/p>\n<p>May you create awesome apps!<\/p>\n<p>it&#8217;d open http:\/\/localhost:8501 on the browser.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12650\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/screenshot-localhost_8501-2025_01_19-22_07_32.png\" alt=\"\" width=\"1553\" height=\"551\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/screenshot-localhost_8501-2025_01_19-22_07_32.png 1553w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/screenshot-localhost_8501-2025_01_19-22_07_32-300x106.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/screenshot-localhost_8501-2025_01_19-22_07_32-1024x363.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/screenshot-localhost_8501-2025_01_19-22_07_32-768x272.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/screenshot-localhost_8501-2025_01_19-22_07_32-1536x545.png 1536w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/screenshot-localhost_8501-2025_01_19-22_07_32-1200x426.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>Create new app and run it<br \/>\nIn your project directory (\/home\/satria\/Documents\/projects\/python\/streamlit) that exist .venv file, create a new file &#8216;app.py&#8217;<\/p>\n<div>[codesyntax lang=&#8221;python&#8221;]<\/p>\n<pre>import streamlit as st\r\n\r\nst.write(\"Hello World\")<\/pre>\n<p>[\/codesyntax]<\/p><\/div>\n<div><\/div>\n<div><\/div>\n<div>then run it.<br \/>\nnote: pls make sure you&#8217;re already in the virtual environment (venv). if not type &#8216;source .venv\/bin\/activate&#8217; to activate it. then run it by typing &#8216;streamlit run app.py&#8217;:<br \/>\nsatria@teddy:~\/Documents\/projects\/python\/streamlit$ source .venv\/bin\/activate<br \/>\n(.venv) satria@teddy:~\/Documents\/projects\/python\/streamlit$ streamlit run app.py<\/p>\n<p>You can now view your Streamlit app in your browser.<\/p>\n<p>Local URL: http:\/\/localhost:8501<br \/>\nNetwork URL: http:\/\/192.168.1.23:8501<\/p>\n<p>it&#8217;ll open it on your browser and printed &#8216;Hello World&#8217;<\/p>\n<\/div>\n<p>&#8230;.<\/p>\n<p>if you already finished, you can stop the streamlit app with ctrl+c and deactivated the venv<br \/>\n^C Stopping&#8230;<br \/>\n(.venv) satria@teddy:~\/Documents\/projects\/python\/streamlit$ deactivate<br \/>\nsatria@teddy:~\/Documents\/projects\/python\/streamlit$<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Check the installed python satria@teddy:~$ pip -V pip 22.0.2 from \/usr\/lib\/python3\/dist-packages\/pip (python 3.10) it seems I already installed python 3. but when I want to find out the location with &#8216;whereis python&#8217;, it showed up nothing satria@teddy:~$ whereis python python: so use &#8216;whereis python3&#8217; instead satria@teddy:~$ whereis python3 python3: \/usr\/bin\/python3 \/usr\/lib\/python3 \/etc\/python3 \/usr\/share\/python3 \/usr\/share\/man\/man1\/python3.1.gz I &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2025\/01\/19\/python-and-streamlit-on-ubuntu-22-04\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Python and Streamlit on Ubuntu 22.04&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-12644","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/12644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=12644"}],"version-history":[{"count":8,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/12644\/revisions"}],"predecessor-version":[{"id":12653,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/12644\/revisions\/12653"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=12644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=12644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=12644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}