question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: partially initialized module 'wandb' has no attribute 'Api' (most likely due to a circular import)

See original GitHub issue

wandb --version && python --version && uname

  • Weights and Biases version: 0.9.4
  • Python version: 3.8
  • Operating System: Ubuntu

Description

wandb has no attribute Api when trying to run on my laptop and github actions.

Error message on local (macOS 10.15.6): AttributeError: module 'wandb' has no attribute 'Api'

Error message on github actions: AttributeError: partially initialized module 'wandb' has no attribute 'Api' (most likely due to a circular import)

What I Did

Same code from the docs, modified to my needs

import os
import datetime
import pandas
import wandb
import json

os.environ['WANDB_API_KEY'] = '*******************************'

api = wandb.Api()

projects = api.projects()
project_list = [p.name for p in projects]
entity = [p.entity for p in projects]

summary_list = []
config_list = []
name_list = []

for i, p in enumerate(project_list):
    for run in api.runs(f'{entity[i]}/{p}'):
        # run.summary are the output key/values like accuracy.
        # We call ._json_dict to omit large files
        summary_list.append(run.summary._json_dict)

        # run.config is the input metrics.
        # We remove special values that start with _.
        config = {k: v for k, v in run.config.items() if not k.startswith('_')}
        config_list.append(config)

        # run.name is the name of the run.
        name_list.append(run.name)

    summary_df = pd.DataFrame.from_records(summary_list)
    config_df = pd.DataFrame.from_records(config_list)
    name_df = pd.DataFrame({'name': name_list})
    df = pd.concat([name_df, config_df, summary_df], axis=1)
    d = dict(df.loc[df['epoch_train_loss'].idxmin()])

    with open(f'{p}.json', 'w') as f:
        json.dump(d, f)

Error trace from github actions ⬇️

Screen Shot 2020-08-05 at 15 15 07

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
tyomhakcommented, Aug 5, 2020

hey @ydcjeff can you please rename the file from wandb.py to something else, and make sure there is no file named wandb.py in the directory, and try running the code again?

1reaction
tyomhakcommented, Aug 5, 2020

Thank you for reporting! Looking into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

partially initialized module 'wandb' has no attribute 'Api' (most ...
AttributeError : partially initialized module 'wandb' has no attribute 'Api' (most likely due to a circular import) #1186.
Read more >
How to fix AttributeError: partially initialized module? [duplicate]
So my code was actually importing that file and not the actual requests ... "Most likely due to a circular import" refers to...
Read more >
attributeerror: module 'wandb' has no attribute 'init' - You.com
... in <module> run = wandb.init( AttributeError: partially initialized module 'wandb' has no attribute 'init' (most likely due to a circular import).
Read more >
AttributeError: partially initialized module has no attribute ...
AttributeError : partially initialized module 'MODULE_NAME' has no attribute 'ATTRIBUTE_NAME' (most likely due to a circular import).
Read more >
module 'wandb' has no attribute 'init'とでたら - Qiita
AttributeError : module 'wandb' has no attribute 'init'. とエラーがでた。前は動いてたはずなのに... Copied! pip install --upgrade wandb.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found