# Failed to detect the name of this notebook, you can set it manually with the WANDB\_NOTEBOOK\_NAME env

**URL:** <https://community.wandb.ai/t/failed-to-detect-the-name-of-this-notebook-you-can-set-it-manually-with-the-wandb-notebook-name-env/6065>\
**Category:** W&B Help\
**Tags:** wandb\
**Created:** [March 8, 2024, 10:14am UTC](https://community.wandb.ai/t/failed-to-detect-the-name-of-this-notebook-you-can-set-it-manually-with-the-wandb-notebook-name-env/6065 "2024-03-08T10:14:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sara-k](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@sara-k](https://community.wandb.ai/u/sara-k)\
**Post date:** [March 8, 2024, 10:14am UTC](https://community.wandb.ai/t/failed-to-detect-the-name-of-this-notebook-you-can-set-it-manually-with-the-wandb-notebook-name-env/6065/1 "2024-03-08T10:14:24Z")

</div>

In Visual Studio Code, first I encounted issues logging into wandb. I’ve tried specifying the entity as ‘myusername’, but it hasn’t resolved the problem. I’ve also confirmed that I’m using the latest version of wandb. My project folder is located on the Desktop.

```auto
import os

os.environ["WANDB_API_KEY"] = 'API_KEY'
!wandb login API_KEY

```

When I tried to initialize wandb (wandb.init()), I’m got the following error:

```auto
Changes to your `wandb` environment variables will be ignored because your `wandb` session has already started. For more information on how to modify your settings with `wandb.init()` arguments, please refer to [the W&B docs](https://wandb.me/wandb-init).
wandb: ERROR Error while calling W&B API: user is not logged in (<Response [401]>)

```

Then I decided to run it on terminal insisted of jupyter notebook cell but I got this error  
`Failed to detect the name of this notebook, you can set it manually with the WANDB_NOTEBOOK_NAME environment variable to enable code saving.`

Any suggestions on how to resolve this?"

---

<div class="post-metadata">

**Author:** ![fmamberti-wandb](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@fmamberti-wandb](https://community.wandb.ai/u/fmamberti-wandb)\
**Post date:** [March 13, 2024, 9:37am UTC](https://community.wandb.ai/t/failed-to-detect-the-name-of-this-notebook-you-can-set-it-manually-with-the-wandb-notebook-name-env/6065/2 "2024-03-13T09:37:30Z")

</div>

Hi @sara-k , thank you for reaching out and sorry to hear you are experiencing this.

In the Notebook could you try replacing

`!wandb login API_KEY`

with

`wandb.login(key=os.environ["WANDB_API_KEY"])`

and let me know if you can log runs successfully?

Alternatively, what is the output if you run `wandb login` directly in your terminal ?(without the API\_KEY)

---

<div class="post-metadata">

**Author:** ![fmamberti-wandb](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@fmamberti-wandb](https://community.wandb.ai/u/fmamberti-wandb)\
**Post date:** [March 15, 2024, 1:02pm UTC](https://community.wandb.ai/t/failed-to-detect-the-name-of-this-notebook-you-can-set-it-manually-with-the-wandb-notebook-name-env/6065/3 "2024-03-15T13:02:00Z")

</div>

Hi @sara-k , I wanted to follow up on this request. Please let us know if we can be of further assistance or if your issue has been resolved.

---

<div class="post-metadata">

**Author:** ![fmamberti-wandb](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@fmamberti-wandb](https://community.wandb.ai/u/fmamberti-wandb)\
**Post date:** [March 19, 2024, 6:14pm UTC](https://community.wandb.ai/t/failed-to-detect-the-name-of-this-notebook-you-can-set-it-manually-with-the-wandb-notebook-name-env/6065/4 "2024-03-19T18:14:19Z")

</div>

Hi @sara-k , 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!
