# Login or init error in google colab

**URL:** <https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632>\
**Category:** W&B Help\
**Tags:** wandb\
**Created:** [June 27, 2023, 3:16am UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632 "2023-06-27T03:16:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gno33](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@gno33](https://community.wandb.ai/u/gno33)\
**Post date:** [June 27, 2023, 3:16am UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/1 "2023-06-27T03:16:55Z")

</div>

I am getting some errors when running wandb on google colab.

1. wandb.login() not working  
It will run for a while, and then the screen will change to a white Google Chrome error screen, showing error code 5.

If I refresh Chrome and go back to colab, wandb.login is still running and if you force it to stop, you will see an error message like below.

```auto
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-2-f4bc2b362420> in <cell line: 1>()
----> 1 wandb.login()

7 frames
/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in login(anonymous, key, relogin, host, force, timeout)
     75 return True
     76 kwargs = dict(locals())
---> 77 configured = _login(**kwargs)
     78 return True if configured else False
     79 

/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in _login(anonymous, key, relogin, host, force, timeout, _backend, _silent, _disable_warning, _entity)
    296 
    297 if not key:
--> 298 wlogin.prompt_api_key()
    299 
    300 # make sure login credentials get to the backend

/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in prompt_api_key(self)
    219 
    220 def prompt_api_key(self):
--> 221 key, status = self._prompt_api_key()
    222 if status == ApiKeyStatus.NOTTY:
    223 directive = (

/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in _prompt_api_key(self)
    199 while True:
    200 try:
--> 201 key = apikey.prompt_api_key(
    202 self._settings,
    203 api=api,

/usr/local/lib/python3.10/dist-packages/wandb/sdk/lib/apikey.py in prompt_api_key(settings, api, input_callback, browser_callback, no_offline, no_create, local)
     88 if jupyter and "google.colab" in sys.modules:
     89 log_string = term.LOG_STRING_NOCOLOR
---> 90 key = wandb.jupyter.attempt_colab_login(app_url)
     91 if key is not None:
     92 write_key(settings, key, api=api)

/usr/local/lib/python3.10/dist-packages/wandb/jupyter.py in attempt_colab_login(app_url)
    321 )
    322 try:
--> 323 return output.eval_js("_wandbApiKey")
    324 except MessageError:
    325 return None

/usr/local/lib/python3.10/dist-packages/google/colab/output/_js.py in eval_js(script, ignore_result, timeout_sec)
     38 if ignore_result:
     39 return
---> 40 return _message.read_reply_from_input(request_id, timeout_sec)
     41 
     42 

/usr/local/lib/python3.10/dist-packages/google/colab/_message.py in read_reply_from_input(message_id, timeout_sec)
     94 reply = _read_next_input_message()
     95 if reply == _NOT_READY or not isinstance(reply, dict):
---> 96 time.sleep(0.025)
     97 continue
     98 if (

KeyboardInterrupt: 

```

The commands below sometimes work to log in.

```auto
! wandb login

```

Sometimes wandb.init() doesn’t work well even if the login is successful. When i run wandb.init() or run the next cell after init, colab runtime will be disconnected and reconnected after a small wait. After that, logging is sometimes fine. However, this disconnection is very disruptive for iterative experiments.

---

<div class="post-metadata">

**Author:** ![uma-wandb](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uma-wandb](https://community.wandb.ai/u/uma-wandb)\
**Post date:** [June 29, 2023, 4:55pm UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/2 "2023-06-29T16:55:41Z")

</div>

Hey gnokim,

Sorry to hear this is happening. I have a few questions to help me investigate this issue further:

- What version of wandb are you running?
- Even after resetting the Colab runtime, does this still occur?
- What happens when you try to log in via `wandb.login(key='YOUR_API_KEY')?`
- Could you elaborate on what you mean by “wandb.init() doesn’t work well even if the login is successful” ? Does this mean you are able to initialize a wandb run, but it is slow? Or is it unable to be spun up at all?

Thanks for providing this information!

Best,

Uma

---

<div class="post-metadata">

**Author:** ![uma-wandb](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uma-wandb](https://community.wandb.ai/u/uma-wandb)\
**Post date:** [July 5, 2023, 5:23pm UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/3 "2023-07-05T17:23:51Z")

</div>

Hi gnokim, since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!

---

<div class="post-metadata">

**Author:** ![gno33](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@gno33](https://community.wandb.ai/u/gno33)\
**Post date:** [July 6, 2023, 2:08am UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/4 "2023-07-06T02:08:58Z")

</div>

Sorry for the late reply, I missed yours, I’m still stuck on the issue, I’ll reply soon.

---

<div class="post-metadata">

**Author:** ![gno33](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@gno33](https://community.wandb.ai/u/gno33)\
**Post date:** [July 6, 2023, 3:00am UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/5 "2023-07-06T03:00:41Z")

</div>

[https://drive.google.com/drive/folders/1tnNOmO7dYMnVPk6TjbBF\_qmOXfnHxklX?usp=sharing](https://drive.google.com/drive/folders/1tnNOmO7dYMnVPk6TjbBF_qmOXfnHxklX?usp=sharing)

The code below sometimes works and sometimes doesn’t.  
wandb.login(key=‘YOUR\_API\_KEY’)

The main problem is that it doesn’t run smoothly from login to init.

---

<div class="post-metadata">

**Author:** ![uma-wandb](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uma-wandb](https://community.wandb.ai/u/uma-wandb)\
**Post date:** [July 6, 2023, 6:19pm UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/6 "2023-07-06T18:19:50Z")

</div>

Hey @gno33, I recommend continuing to use the workaround with `! wandb login` for the time being, as well as trying the following:

- Running wandb in offline mode. Documentation can be found [here](https://docs.wandb.ai/guides/technical-faq/setup#can-i-run-wandb-offline) and here’s the [documentation](https://docs.wandb.ai/guides/track/tracking-faq#is-it-possible-to-save-metrics-offline-and-sync-them-to-wb-later) on saving metrics offline and syncing them to wandb later
- Disabling any firewalls that could be interfering with the network

Please let me know if any of these suggestions help in any way.

---

<div class="post-metadata">

**Author:** ![uma-wandb](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uma-wandb](https://community.wandb.ai/u/uma-wandb)\
**Post date:** [July 10, 2023, 9:43pm UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/7 "2023-07-10T21:43:29Z")

</div>

Hi @gno33, since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [September 4, 2023, 6:20pm UTC](https://community.wandb.ai/t/login-or-init-error-in-google-colab/4632/8 "2023-09-04T18:20:39Z")

</div>

Closed on September 4, 2023, 6:20pm UTC

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