# Login form

**URL:** <https://discuss.streamlit.io/t/login-form/35914>\
**Category:** Using Streamlit\
**Created:** [January 10, 2023, 2:02pm UTC](https://discuss.streamlit.io/t/login-form/35914 "2023-01-10T14:02:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [January 10, 2023, 2:02pm UTC](https://discuss.streamlit.io/t/login-form/35914/1 "2023-01-10T14:02:33Z")

</div>

Hello i’m a new user of streamlit and i am trying to do a login form, but i face some issues.  
I tried to use the streamlit-authenticator library, i used the script bellow :

import streamlit as st  
import pickle  
from pathlib import Path  
import streamlit\_authenticator as stauth

# 

st.set\_page\_config(page\_title=“app”, layout=“wide”)

names = [“User1 name1”, “User2 name2”]  
usernames = [“uname1”, “uname2”]

# load hashed passwords

file\_path = Path( **file** ).parent / “hashed\_pw.pkl”  
with file\_path.open(“rb”) as file:  
hashed\_passwords = pickle.load(file)

authenticator = stauth.Authenticate(names, usernames, hashed\_passwords,  
“App”, “abcdef”, cookie\_expiry\_days=30)

name, authentication\_status, username = authenticator.login(“Login”, “main”)

if authentication\_status == False:  
st.error(“Username/password is incorrect”)

if authentication\_status == None:  
st.warning(“Please enter your username and password”)

if authentication\_status:  
“Body App”

Note : I stored the passwords in hashed\_pw.pkl file.

When i run that code, i got this Error : streamlit.runtime.scriptrunner.script\_runner.StopException File “path”, loginobj = login(auth\_token = “courier\_auth\_token”.

What can i do to resolve this ?  
Also, if there is another library to do this, i take it.

Thank you for you answers !  
Happy streamlit ing

---

<div class="post-metadata">

**Author:** ![ferdy](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ferdy/32/29957_2.png) [@ferdy](https://discuss.streamlit.io/u/ferdy)\
**Post date:** [January 10, 2023, 2:57pm UTC](https://discuss.streamlit.io/t/login-form/35914/2 "2023-01-10T14:57:41Z")

</div>

Have a look at this [streamlit\_login\_auth\_ui](https://github.com/GauriSP10/streamlit_login_auth_ui) authenticator.

Sample code from site.

```auto
import streamlit as st
from streamlit_login_auth_ui.widgets import __login__

__login__ obj = __login__ (auth_token = "courier_auth_token", 
                    company_name = "Shims",
                    width = 200, height = 250, 
                    logout_button_name = 'Logout', hide_menu_bool = False, 
                    hide_footer_bool = False, 
                    lottie_url = 'https://assets2.lottiefiles.com/packages/lf20_jcikwtux.json')

LOGGED_IN = __login__ obj.build_login_ui()

if LOGGED_IN:

    st.markown("Your Streamlit Application Begins here!")

```

If you are comfortable with that, you can try the [PR](https://github.com/GauriSP10/streamlit_login_auth_ui/pull/10) I made with some improvements.

You can also try the [Streamlit Authentication without SSO](https://docs.streamlit.io/knowledge-base/deploy/authentication-without-sso).

---

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [January 10, 2023, 3:21pm UTC](https://discuss.streamlit.io/t/login-form/35914/3 "2023-01-10T15:21:11Z")

</div>

Hello fredy, thank you for the reply.  
About the example code you give me, in order to try it, i installed :

- pip install streamlit-login-auth-ui
- pip install argon2-cffi

And after runing the same code, i got this error :  
Traceback (most recent call last) :  
File “path”, line 6, in \_\_login\_\_obj = **login** (auth\_token = “courier\_auth\_token”,  
File “path”, line 54, in \_\_init\_\_st.stop()  
File “path”, line 41, in stop raise StopException()  
streamlit.runtime.scriptrunner.script\_runner.StopException

can you help me fixing this ?

---

<div class="post-metadata">

**Author:** ![ferdy](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ferdy/32/29957_2.png) [@ferdy](https://discuss.streamlit.io/u/ferdy)\
**Post date:** [January 10, 2023, 3:24pm UTC](https://discuss.streamlit.io/t/login-form/35914/4 "2023-01-10T15:24:50Z")

</div>

May I know the following.

OS?  
Streamlit version?  
Python version?

---

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [January 10, 2023, 6:41pm UTC](https://discuss.streamlit.io/t/login-form/35914/5 "2023-01-10T18:41:25Z")

</div>

Of course, here are the information:  
i an using :  
Windows 10  
Streamlit, version 1.16.0  
Python 3.10.5

---

<div class="post-metadata">

**Author:** ![ferdy](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ferdy/32/29957_2.png) [@ferdy](https://discuss.streamlit.io/u/ferdy)\
**Post date:** [January 10, 2023, 11:53pm UTC](https://discuss.streamlit.io/t/login-form/35914/6 "2023-01-10T23:53:41Z")

</div>

Let’s try the following setup.

1. Open powershell and create a temp\_streamlit folder from your c drive or any drive.

![image](https://global.discourse-cdn.com/streamlit/original/3X/a/9/a9beb9d9c911615ad1aa9d9c48ff57636509ea20.png)

1. cd to temp\_streamlit folder and check you python version.

![image](https://global.discourse-cdn.com/streamlit/original/3X/6/2/6280daf8526472f0a2ccfc25b05d047c2fba3177.png)

1. Create a virtual environment folder called venv with:  
python -m venv venv

![image](https://global.discourse-cdn.com/streamlit/original/3X/a/3/a38cb9c03b1dc4deff81106111e94e5eb37cac39.png)

1. Clone the repo of aut ui with:  
git clone `https://github.com/GauriSP10/streamlit_login_auth_ui`

![image](https://global.discourse-cdn.com/streamlit/original/3X/9/3/93d2447ccd956d7b91c42033409a3c5c14d48c86.png)

1. Activate the virtual environment. We will install streamlit and other needed packages.  
`./venv/scripts/activate`

![image](https://global.discourse-cdn.com/streamlit/original/3X/0/a/0a2a5dd48c711226761d34d1b3f331f3ef66c8a4.png)

1. Update pip with:  
python -m pip install pip -U

2. Install streamlit with:  
pip install streamlit

3. Install the auth ui package with:  
pip install streamlit-login-auth-ui

4. Install argon with:  
pip install argon2-cffi

5. cd to the aut ui folder and run the app.  
There is app.py under `streamlit_login_auth_ui` folder.

![image](https://global.discourse-cdn.com/streamlit/original/3X/5/f/5f853cdae942696bb8570edbe820320d233142ee.png)

You should see something like this.

 ![image](https://global.discourse-cdn.com/streamlit/original/3X/7/f/7f42400d8bc5735f5c28b073fdd4444a350a355c.png)

If you no longer need it, just delete `temp_streamlit` folder.

---

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [January 11, 2023, 12:32am UTC](https://discuss.streamlit.io/t/login-form/35914/7 "2023-01-11T00:32:51Z")

</div>

Oh Thank you so much, i followed your steps and it works. i just have a last question : when i run the script using the play button i got this error (in my first message), but when i write in the terminal : “streamlit run app.py” it works correctly. it’s confusing me

---

<div class="post-metadata">

**Author:** ![ferdy](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ferdy/32/29957_2.png) [@ferdy](https://discuss.streamlit.io/u/ferdy)\
**Post date:** [January 11, 2023, 12:42am UTC](https://discuss.streamlit.io/t/login-form/35914/8 "2023-01-11T00:42:07Z")

</div>

> [@Snow\_Yoo](#):
>
> when i run the script using the play button

I don’t understand that. What is play button?

---

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [January 11, 2023, 10:17am UTC](https://discuss.streamlit.io/t/login-form/35914/9 "2023-01-11T10:17:51Z")

</div>

i am using visual studio code, as ide, i am talking About the “Run python file” button

---

<div class="post-metadata">

**Author:** ![ferdy](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ferdy/32/29957_2.png) [@ferdy](https://discuss.streamlit.io/u/ferdy)\
**Post date:** [January 11, 2023, 1:49pm UTC](https://discuss.streamlit.io/t/login-form/35914/10 "2023-01-11T13:49:40Z")

</div>

Ahh ok, I also use vs code. But I don’t use that button to run streamlit.

---

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [January 11, 2023, 1:53pm UTC](https://discuss.streamlit.io/t/login-form/35914/11 "2023-01-11T13:53:36Z")

</div>

Ok, Thank you very much for your help !

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [January 11, 2024, 1:54pm UTC](https://discuss.streamlit.io/t/login-form/35914/12 "2024-01-11T13:54:10Z")

</div>

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