Module 'wandb' has no attribute 'apis'

Hello, I’m trying to use wandb in a project I’m running on a server via SSH. I created and configured the virtual environment, but with wandb, I’m encountering the error ‘module ‘wandb’ has no attribute ‘apis’’. The server is running Python 3.6.8 and has wandb-0.15.12 installed. However, when I use ‘wandb login’ or any other wandb command, it throws the error. Could anyone help me resolve this issue?

Traceback (most recent call last):
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/bin/wandb", line 5, in <module>
    from wandb.cli.cli import cli
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/__init__.py", line 27, in <module>
    from wandb import sdk as wandb_sdk
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/sdk/__init__.py", line 4, in <module>
    from .artifacts.artifact import Artifact  # noqa: F401
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/sdk/artifacts/artifact.py", line 36, in <module>
    from wandb.apis.normalize import normalize_exceptions
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/apis/__init__.py", line 44, in <module>
    from .public import Api as PublicApi  # noqa
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/apis/public.py", line 51, in <module>
    from wandb.sdk.launch.errors import LaunchError
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/sdk/launch/__init__.py", line 1, in <module>
    from ._launch import launch
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/sdk/launch/_launch.py", line 12, in <module>
    from .agent import LaunchAgent
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/sdk/launch/agent/__init__.py", line 1, in <module>
    from .agent import LaunchAgent
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/sdk/launch/agent/agent.py", line 15, in <module>
    from wandb.sdk.launch._launch_add import launch_add
  File "/home/tcouto/mestrado_andrey/psla/venv-psla/lib64/python3.6/site-packages/wandb/sdk/launch/_launch_add.py", line 5, in <module>
    import wandb.apis.public as public
AttributeError: module 'wandb' has no attribute 'apis'

Hi @andreysr

Thank you for reaching out to support. I’ll be gladly assist you with this. Can you confirm the following points to ensure that everything is properly set up:

  • Can you send as the stack trace of the error
  • Create a new fresh env
  • Install latest wandb sdk with pip install wandb
  • Execute wandb login

Regards,
Carlo Argel

Hi,
in a new fresh env

  from dataclasses import asdict, is_dataclass
ModuleNotFoundError: No module named 'dataclasses'

Hi @andreysr

When you run the latest wandb sdk with pip install wandb, are you receiving this error?

from dataclasses import asdict, is_dataclass
ModuleNotFoundError: No module named ‘dataclasses’

thi is what i see with the latest wandb sdk with pip install wandb

Collecting wandb
  Using cached wandb-0.15.12-py3-none-any.whl (2.1 MB)
Requirement already satisfied: psutil>=5.0.0 in ./venv-psla/lib/python3.6/site-packages (from wandb) (5.9.5)
Requirement already satisfied: setproctitle in ./venv-psla/lib/python3.6/site-packages (from wandb) (1.2.3)
Requirement already satisfied: sentry-sdk>=1.0.0 in ./venv-psla/lib/python3.6/site-packages (from wandb) (1.31.0)
Requirement already satisfied: GitPython!=3.1.29,>=1.0.0 in ./venv-psla/lib/python3.6/site-packages (from wandb) (3.1.18)
Requirement already satisfied: Click!=8.0.0,>=7.1 in ./venv-psla/lib/python3.6/site-packages (from wandb) (8.0.4)
Requirement already satisfied: docker-pycreds>=0.4.0 in ./venv-psla/lib/python3.6/site-packages (from wandb) (0.4.0)
Requirement already satisfied: pathtools in ./venv-psla/lib/python3.6/site-packages (from wandb) (0.1.2)
Requirement already satisfied: protobuf!=4.21.0,<5,>=3.12.0 in ./venv-psla/lib/python3.6/site-packages (from wandb) (3.19.6)
Requirement already satisfied: typing-extensions in ./venv-psla/lib/python3.6/site-packages (from wandb) (4.1.1)
Requirement already satisfied: appdirs>=1.4.3 in ./venv-psla/lib/python3.6/site-packages (from wandb) (1.4.4)
Requirement already satisfied: PyYAML in ./venv-psla/lib/python3.6/site-packages (from wandb) (6.0.1)
Requirement already satisfied: setuptools in ./venv-psla/lib/python3.6/site-packages (from wandb) (39.2.0)
Requirement already satisfied: requests<3,>=2.0.0 in ./venv-psla/lib/python3.6/site-packages (from wandb) (2.27.1)
Requirement already satisfied: importlib-metadata in ./venv-psla/lib/python3.6/site-packages (from Click!=8.0.0,>=7.1->wandb) (4.8.3)
Requirement already satisfied: six>=1.4.0 in ./venv-psla/lib/python3.6/site-packages (from docker-pycreds>=0.4.0->wandb) (1.16.0)
Requirement already satisfied: gitdb<5,>=4.0.1 in ./venv-psla/lib/python3.6/site-packages (from GitPython!=3.1.29,>=1.0.0->wandb) (4.0.9)
Requirement already satisfied: idna<4,>=2.5 in ./venv-psla/lib/python3.6/site-packages (from requests<3,>=2.0.0->wandb) (3.4)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./venv-psla/lib/python3.6/site-packages (from requests<3,>=2.0.0->wandb) (2.0.12)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./venv-psla/lib/python3.6/site-packages (from requests<3,>=2.0.0->wandb) (1.26.17)
Requirement already satisfied: certifi>=2017.4.17 in ./venv-psla/lib/python3.6/site-packages (from requests<3,>=2.0.0->wandb) (2023.7.22)
Requirement already satisfied: smmap<6,>=3.0.1 in ./venv-psla/lib/python3.6/site-packages (from gitdb<5,>=4.0.1->GitPython!=3.1.29,>=1.0.0->wandb) (5.0.0)
Requirement already satisfied: zipp>=0.5 in ./venv-psla/lib/python3.6/site-packages (from importlib-metadata->Click!=8.0.0,>=7.1->wandb) (3.6.0)
Installing collected packages: wandb
Successfully installed wandb-0.15.12

Hi @andreysr ,

Can you check on your end if/can you successfully import wandb (import wandb)?

Regards,
Carlo Argel

I have the same error. I cannot import wandb and the error comes out. I think python version matters? I have python 3.6.15.

Hello, I found that this happens due to some library dependency that ‘wandb’ has. I have a file that installs several libraries, and in the end, ‘wandb’ works without this error. I’m not sure which library it is, but this is the solution

Could you please share the libraries? Many thanks in advance.

having the same issue. any help would be appreciated

Hi @alenakim @andreysr @u6766669 @baj321, there appears to be some incompatibility issues with certain packages that use older versions of python. Note wandb will no longer support python 3.6 as of sdk release 0.16.0 releasing soon.

  • currently prior to wandb<0.16.0, we support the use of python version 3.6
  • with the release of wandb==0.16.0 we won’t support python version 3.6
  • if you use python 3.6 in your code, you should either update your python (if you can and want) or continue using a version before wandb==0.16.0

We recommend upgrading your python version and seeing if this addresses the import errors you are seeing.

@u6766669 @alenakim

the libraries i used

pip install antlr4-python3-runtime==4.8
pip install appdirs==1.4.4
pip install attrdict==2.0.1
pip install audioread==3.0.1
pip install certifi==2023.7.22
pip install cffi==1.15.1
pip install charset-normalizer==2.0.12
pip install click==8.0.4
pip install colorlog==6.6.0
pip install cycler==0.11.0
pip install dataclasses==0.8
pip install datasets==1.11.0
pip install decorator==5.1.1
pip install dill==0.3.4
pip install docker-pycreds==0.4.0
pip install et-xmlfile==1.1.0
pip install filelock==3.4.1
pip install fsspec==2022.1.0
pip install gitdb==4.0.9
pip install GitPython==3.1.18
pip install huggingface-hub==0.0.19
pip install hydra-colorlog==1.1.0
pip install hydra-core==1.1.1
pip install idna==3.4
pip install importlib-metadata==4.8.3
pip install importlib-resources==5.4.0
pip install joblib==1.1.1
pip install kiwisolver==1.3.1
pip install librosa==0.8.1
pip install llvmlite==0.36.0
pip install lshw==0.0.1
pip install matplotlib==3.3.4
pip install multiprocess==0.70.12.2
pip install numba==0.53.1
pip install numpy==1.19.5
pip install omegaconf==2.1.2
pip install openpyxl==3.0.9
pip install packaging==21.3
pip install pandas==1.1.5
pip install pathtools==0.1.2
pip install Pillow==8.4.0
pip install pooch==1.6.0
pip install protobuf==3.19.6
pip install psutil==5.9.5
pip install pyarrow==6.0.1
pip install pycparser==2.21
pip install pyparsing==3.1.1
pip install python-dateutil==2.8.2
pip install pytz==2023.3.post1
pip install PyYAML==6.0.1
pip install regex==2023.8.8
pip install requests==2.27.1
pip install resampy==0.4.2
pip install sacremoses==0.0.53
pip install scikit-learn==0.24.2
pip install scipy==1.5.4
pip install seaborn==0.11.2
pip install sentry-sdk==1.31.0
pip install setproctitle==1.2.3
pip install six==1.16.0
pip install sklearn==0.0
pip install smmap==5.0.0
pip install soundfile==0.12.1
pip install threadpoolctl==3.1.0
pip install timm==0.4.5
pip install tokenizers==0.10.3
pip install torch==1.10.1
pip install torchaudio==0.10.1
pip install torchvision==0.11.2
pip install tqdm==4.64.1
pip install transformers==4.11.3
pip install typing_extensions==4.1.1
pip install urllib3==1.26.17
pip install wandb==0.15.11
pip install xxhash==3.2.0
pip install zipp==3.6.0

Thanks for sharing, solved!
My previous wandb version is 0.15.12, after installing 0.15.11, the problem was solved.
`pip install wandb==0.15.11

2 Likes

Hi there,

Thank you for informing that it helps solved your concern. I’ll proceed in closing this ticket but please don’t hesitate to reach back out anytime you need more assistance.

Regards,
Carlo Argel

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