ServiceStartProcessError at wandb.login()

I have an issue that seems to have been raised in a few other threads but for some reason none of those solutions are working for me. I am running wandb.login() in a jupyter notebook and receiving the following error:

Traceback (most recent call last):
  File "/private/var/tmp/_bazel_me/c6c153b8ee296ecf5ef55e689ef4faf0/external/python3_aarch64-apple-darwin/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/private/var/tmp/_bazel_me/c6c153b8ee296ecf5ef55e689ef4faf0/external/python3_aarch64-apple-darwin/lib/python3.10/runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/private/var/tmp/_bazel_me/c6c153b8ee296ecf5ef55e689ef4faf0/external/python3_aarch64-apple-darwin/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/__init__.py", line 27, in <module>
    from wandb import sdk as wandb_sdk
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/sdk/__init__.py", line 25, in <module>
    from .artifacts.artifact import Artifact
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact.py", line 36, in <module>
    from wandb.apis.normalize import normalize_exceptions
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/apis/__init__.py", line 43, in <module>
    from .internal import Api as InternalApi  # noqa
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/apis/internal.py", line 3, in <module>
    from wandb.sdk.internal.internal_api import Api as InternalApi
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/sdk/internal/internal_api.py", line 48, in <module>
    from ..lib import retry
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/sdk/lib/retry.py", line 17, in <module>
    from .mailbox import ContextCancelledError
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/sdk/lib/mailbox.py", line 10, in <module>
    from wandb.proto import wandb_internal_pb2 as pb
  File "/Users/me/.local/lib/python3.10/site-packages/wandb/proto/wandb_internal_pb2.py", line 1, in <module>
    import google.protobuf
ModuleNotFoundError: No module named 'google.protobuf'

---------------------------------------------------------------------------
ServiceStartProcessError                  Traceback (most recent call last)
Cell In[2], line 25
     22 from sklearn.pipeline import Pipeline
     23 from sklearn.preprocessing import StandardScaler
---> 25 wandb.login()

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_login.py:81, in login(anonymous, key, relogin, host, force, timeout, verify)
     55 """Set up W&B login credentials.
     56 
     57 By default, this will only store the credentials locally without
   (...)
     78     UsageError - if api_key cannot be configured and no tty
     79 """
     80 _handle_host_wandb_setting(host)
---> 81 if wandb.setup()._settings._noop:
     82     return True
     83 kwargs = dict(locals())

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_setup.py:327, in setup(settings)
    324 def setup(
    325     settings: Optional[Settings] = None,
    326 ) -> Optional["_WandbSetup"]:
--> 327     ret = _setup(settings=settings)
    328     return ret

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_setup.py:320, in _setup(settings, _reset)
    318     _WandbSetup._instance = None
    319     return None
--> 320 wl = _WandbSetup(settings=settings)
    321 return wl

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_setup.py:303, in _WandbSetup.__init__(self, settings)
    301     _WandbSetup._instance._update(settings=settings)
    302     return
--> 303 _WandbSetup._instance = _WandbSetup__WandbSetup(settings=settings, pid=pid)

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_setup.py:114, in _WandbSetup__WandbSetup.__init__(self, pid, settings, environ)
    111 wandb.termsetup(self._settings, logger)
    113 self._check()
--> 114 self._setup()
    116 tracelog_mode = self._settings._tracelog
    117 if tracelog_mode:

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_setup.py:250, in _WandbSetup__WandbSetup._setup(self)
    249 def _setup(self) -> None:
--> 250     self._setup_manager()
    252     sweep_path = self._settings.sweep_param_path
    253     if sweep_path:

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_setup.py:277, in _WandbSetup__WandbSetup._setup_manager(self)
    275 if self._settings._disable_service:
    276     return
--> 277 self._manager = wandb_manager._Manager(settings=self._settings)

File ~/.local/lib/python3.10/site-packages/wandb/sdk/wandb_manager.py:139, in _Manager.__init__(self, settings)
    137 token = _ManagerToken.from_environment()
    138 if not token:
--> 139     self._service.start()
    140     host = "localhost"
    141     transport = "tcp"

File ~/.local/lib/python3.10/site-packages/wandb/sdk/service/service.py:237, in _Service.start(self)
    236 def start(self) -> None:
--> 237     self._launch_server()

File ~/.local/lib/python3.10/site-packages/wandb/sdk/service/service.py:231, in _Service._launch_server(self)
    229     self._wait_for_ports(fname, proc=internal_proc)
    230 except Exception as e:
--> 231     _sentry.reraise(e)
    232 self._startup_debug_print("wait_ports_done")
    233 self._internal_proc = internal_proc

File ~/.local/lib/python3.10/site-packages/wandb/analytics/sentry.py:154, in Sentry.reraise(self, exc)
    151 self.exception(exc)
    152 # this will messily add this "reraise" function to the stack trace,
    153 # but hopefully it's not too bad
--> 154 raise exc.with_traceback(sys.exc_info()[2])

File ~/.local/lib/python3.10/site-packages/wandb/sdk/service/service.py:229, in _Service._launch_server(self)
    227 self._startup_debug_print("wait_ports")
    228 try:
--> 229     self._wait_for_ports(fname, proc=internal_proc)
    230 except Exception as e:
    231     _sentry.reraise(e)

File ~/.local/lib/python3.10/site-packages/wandb/sdk/service/service.py:107, in _Service._wait_for_ports(self, fname, proc)
     92 if proc and proc.poll():
     93     # process finished
     94     # define these variables for sentry context grab:
   (...)
     98     # proc_out = proc.stdout.read()
     99     # proc_err = proc.stderr.read()
    100     context = dict(
    101         command=proc.args,
    102         sys_executable=sys.executable,
   (...)
    105         proc_err=proc.stderr.read() if proc.stderr else "",
    106     )
--> 107     raise ServiceStartProcessError(
    108         f"The wandb service process exited with {proc.returncode}. "
    109         "Ensure that `sys.executable` is a valid python interpreter. "
    110         "You can override it with the `_executable` setting "
    111         "or with the `WANDB__EXECUTABLE` environment variable.",
    112         context=context,
    113     )
    114 if not os.path.isfile(fname):
    115     time.sleep(0.2)

ServiceStartProcessError: The wandb service process exited with 1. Ensure that `sys.executable` is a valid python interpreter. You can override it with the `_executable` setting or with the `WANDB__EXECUTABLE` environment variable.

I am using wandb version 0.16.1. As you can see I am executing the code from within a jupyter notebook launched from a bazel server.

From this post it seems wandb can’t find a python interpreter in my environment. The output of print(sys.executable) is /private/var/tmp/_bazel_me/c6c153b8ee296ecf5ef55e689ef4faf0/execroot/bazel-out/darwin_arm64-fastbuild/jupyter.runfiles/python3_aarch64-apple-darwin/bin/python3 and the output of !python --version is Python 3.11.4.

The current click module is version 8.1.7 and upgrading it did not help nor did downgrading it to version 8.0.4.

Protobuf is showing as installed with version 3.20.3. Thanks very much for any insight you may have.

hey @ht99, have you tried setting WANDB__EXECUTABLE to your Python’s path? Additionally, do you reach this error when trying to login to wandb outside of a bazel server (and preferably in a fresh environment)? Would it also be possible to run !pip install protobuf explicitly before importing wandb and logging in?

Please let me know how any of the above suggestions go

Hi Hailey, 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!

Thanks for your suggestions @uma-wandb and sorry for the delay in response; I’ve just found time to debug this again. I’ve tried the following from within the bazel server:

os.environ['WANDB__EXECUTABLE']=sys.executable

I still get the same error message. I’ve also made sure that protobuf is installed explicitly.
I do not reach this error when logging into wandb outside of a bazel server in a conda env. Here are the differences in package versions between bazel and the working conda server:

Bazel:
Python version==3.10.9
Protobuf==3.20.3
wandb==0.16.2

Conda:
Python version==3.11.7
Protobuf==3.17.2
wandb==0.16.2