# ModuleNotFound: ray.serve.generated

**URL:** <https://discuss.ray.io/t/modulenotfound-ray-serve-generated/5361>\
**Category:** RLlib\
**Created:** [March 10, 2022, 8:47am UTC](https://discuss.ray.io/t/modulenotfound-ray-serve-generated/5361 "2022-03-10T08:47:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Simon\_Zehnder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/lars_simon_zehnder/32/1185_2.png) [@Lars\_Simon\_Zehnder](https://discuss.ray.io/u/Lars_Simon_Zehnder)\
**Post date:** [March 10, 2022, 8:47am UTC](https://discuss.ray.io/t/modulenotfound-ray-serve-generated/5361/1 "2022-03-10T08:47:50Z")

</div>

H guys,

I am working on my fork with the nightly-build and encounter a weird `ModuleNotFound` error.

Following steps I have done:

```auto
pip uninstall -y ray
pip install -U --no-cache-dir "ray[default,tune,rllib,serve] @ https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-2.0.0.dev0-cp39-cp39-manylinux2014_x86_64.whl"
yes | ./python/ray/setup_dev.py

```

(I am installing into a virtualenv with Python 3.9.0)

Then I eecuted the following code:

```auto
import ray
from ray import tune
import ray.rllib.agents.dqn as dqn

MyConfig = dqn.SIMPLE_Q_DEFAULT_CONFIG.copy()
#MyConfig['prioritized_replay'] = False

ray.init(local_mode=True)
tune.run(   
    dqn.SimpleQTrainer,
    config=MyConfig,
    stop={"training_iteration": 4},
    fail_fast=True,
    num_samples=1,
)

```

This results in many errors:

```auto
2022-03-10 09:39:46,720 ERROR services.py:1495 -- Failed to start the dashboard: Failed to start the dashboard, return code 1
 The last 10 lines of /tmp/ray/session_2022-03-10_09-39-44_077317_16632/logs/dashboard.log:
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/ __init__.py", line 2, in <module>
    from ray.serve.api import (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/api.py", line 19, in <module>
    from ray.serve.common import (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/common.py", line 7, in <module>
    from ray.serve.config import DeploymentConfig, ReplicaConfig
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/config.py", line 26, in <module>
    from ray.serve.generated.serve_pb2 import (
ModuleNotFoundError: No module named 'ray.serve.generated'. You can run `pip install "ray[serve]"` to install all Ray Serve dependencies.
2022-03-10 09:39:46,720 ERROR services.py:1496 -- Failed to start the dashboard, return code 1
 The last 10 lines of /tmp/ray/session_2022-03-10_09-39-44_077317_16632/logs/dashboard.log:
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/ __init__.py", line 2, in <module>
    from ray.serve.api import (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/api.py", line 19, in <module>
    from ray.serve.common import (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/common.py", line 7, in <module>
    from ray.serve.config import DeploymentConfig, ReplicaConfig
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/config.py", line 26, in <module>
    from ray.serve.generated.serve_pb2 import (
ModuleNotFoundError: No module named 'ray.serve.generated'. You can run `pip install "ray[serve]"` to install all Ray Serve dependencies.
Traceback (most recent call last):
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/_private/services.py", line 1472, in start_dashboard
    raise Exception(err_msg + last_log_str)
Exception: Failed to start the dashboard, return code 1
 The last 10 lines of /tmp/ray/session_2022-03-10_09-39-44_077317_16632/logs/dashboard.log:
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/ __init__.py", line 2, in <module>
    from ray.serve.api import (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/api.py", line 19, in <module>
    from ray.serve.common import (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/common.py", line 7, in <module>
    from ray.serve.config import DeploymentConfig, ReplicaConfig
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/serve/config.py", line 26, in <module>
    from ray.serve.generated.serve_pb2 import (
ModuleNotFoundError: No module named 'ray.serve.generated'. You can run `pip install "ray[serve]"` to install all Ray Serve dependencies.
2022-03-10 09:39:48,953 WARNING worker.py:551 -- `ray.get_gpu_ids()` will always return the empty list when called from the driver. This is because Ray does not manage GPU allocations to the driver process.
:task_name:bundle_reservation_check_func
:task_name:bundle_reservation_check_func
2022-03-10 09:39:48,954 INFO trial_runner.py:801 -- starting SimpleQTrainer_None_a5410_00000
:actor_name:SimpleQTrainer
:actor_name:SimpleQTrainer
2022-03-10 09:39:49,257 INFO trainer.py:2295 -- Your framework setting is 'tf', meaning you are using static-graph mode. Set framework='tf2' to enable eager execution with tf2.x. You may also then want to set eager_tracing=True in order to reach similar execution speed as with static-graph mode.
2022-03-10 09:39:49,258 INFO simple_q.py:162 -- In multi-agent mode, policies will be optimized sequentially by the multi-GPU optimizer. Consider setting `simple_optimizer=True` if this doesn't work for you.
2022-03-10 09:39:49,258 INFO trainer.py:864 -- Current log_level is WARN. For more information, set 'log_level': 'INFO' / 'DEBUG' or use the -v and -vv flags.
[2022-03-10 09:39:49,265 E 16632 16632] core_worker.cc:1288: Pushed Error with JobID: 01000000 of type: task with message: ray::SimpleQTrainer. __init__ () (pid=16632, ip=192.168.1.102, repr=SimpleQTrainer)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/agents/trainer.py", line 1035, in _init
    raise NotImplementedError
NotImplementedError

During handling of the above exception, another exception occurred:

ray::SimpleQTrainer. __init__ () (pid=16632, ip=192.168.1.102, repr=SimpleQTrainer)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/agents/trainer.py", line 830, in __init__
    super(). __init__ (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/trainable.py", line 149, in __init__
    self.setup(copy.deepcopy(self.config))
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/agents/trainer.py", line 911, in setup
    self.workers = WorkerSet(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/worker_set.py", line 162, in __init__
    self._local_worker = self._make_worker(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/worker_set.py", line 567, in _make_worker
    worker = cls(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/rollout_worker.py", line 569, in __init__
    self.policy_dict = _determine_spaces_for_multi_agent_dict(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/rollout_worker.py", line 1869, in _determine_spaces_for_multi_agent_dict
    raise ValueError(
ValueError: `observation_space` not provided in PolicySpec for default_policy and env does not have an observation space OR no spaces received from other workers' env(s) OR no `observation_space` specified in config! at time: 1.6469e+09
2022-03-10 09:39:49,265 ERROR actor.py:1009 -- Exception raised in creation task: The actor died because of an error raised in its creation task, ray::SimpleQTrainer. __init__ () (pid=16632, ip=192.168.1.102, repr=SimpleQTrainer)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/agents/trainer.py", line 1035, in _init
    raise NotImplementedError
NotImplementedError

During handling of the above exception, another exception occurred:

ray::SimpleQTrainer. __init__ () (pid=16632, ip=192.168.1.102, repr=SimpleQTrainer)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/agents/trainer.py", line 830, in __init__
    super(). __init__ (
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/trainable.py", line 149, in __init__
    self.setup(copy.deepcopy(self.config))
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/agents/trainer.py", line 911, in setup
    self.workers = WorkerSet(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/worker_set.py", line 162, in __init__
    self._local_worker = self._make_worker(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/worker_set.py", line 567, in _make_worker
    worker = cls(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/rollout_worker.py", line 569, in __init__
    self.policy_dict = _determine_spaces_for_multi_agent_dict(
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/rllib/evaluation/rollout_worker.py", line 1869, in _determine_spaces_for_multi_agent_dict
    raise ValueError(
ValueError: `observation_space` not provided in PolicySpec for default_policy and env does not have an observation space OR no spaces received from other workers' env(s) OR no `observation_space` specified in config!
[2022-03-10 09:39:49,270 E 16632 16632] core_worker.cc:1288: Pushed Error with JobID: 01000000 of type: task with message: ray::SimpleQTrainer.get_auto_filled_metrics()::Exiting (pid=16632, ip=192.168.1.102, repr=SimpleQTrainer)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/trainable.py", line 252, in get_auto_filled_metrics
    "warmup_time": self._warmup_time,
AttributeError: 'SimpleQTrainer' object has no attribute '_warmup_time' at time: 1.6469e+09
[2022-03-10 09:39:49,271 E 16632 16632] core_worker.cc:1288: Pushed Error with JobID: 01000000 of type: task with message: ray::SimpleQTrainer.train()::Exiting (pid=16632, ip=192.168.1.102, repr=SimpleQTrainer)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/trainable.py", line 346, in train
    if self._warmup_time is None:
AttributeError: 'SimpleQTrainer' object has no attribute '_warmup_time' at time: 1.6469e+09
Traceback (most recent call last):
  File "/home/simon/git-projects/ray/test_simpleq.py", line 9, in <module>
    tune.run(   
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/tune.py", line 671, in run
    _report_progress(runner, progress_reporter)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/tune.py", line 84, in _report_progress
    reporter.report(trials, done, sched_debug_str, executor_debug_str)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/progress_reporter.py", line 559, in report
    print(self._progress_str(trials, done, *sys_info))
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/progress_reporter.py", line 297, in _progress_str
    user_metrics = self._infer_user_metrics(trials, self._infer_limit)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/progress_reporter.py", line 345, in _infer_user_metrics
    if not t.last_result:
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/trial.py", line 431, in last_result
    self._get_default_result_or_future()
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/trial.py", line 406, in _get_default_result_or_future
    self._default_result_or_future = ray.get(self._default_result_or_future)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/_private/client_mode_hook.py", line 105, in wrapper
    return func(*args, **kwargs)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/worker.py", line 1934, in get
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(AttributeError): ray::SimpleQTrainer.get_auto_filled_metrics()::Exiting (pid=16632, ip=192.168.1.102, repr=SimpleQTrainer)
  File "/home/simon/git-projects/ray/.venv/lib/python3.9/site-packages/ray/tune/trainable.py", line 252, in get_auto_filled_metrics
    "warmup_time": self._warmup_time,
AttributeError: 'SimpleQTrainer' object has no attribute '_warmup_time'

```

I have tried to install `ray.serve` dependencies via

```auto
"ray[serve] @ https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-2.0.0.dev0-cp39-cp39-manylinux2014_x86_64.whl"

```

but this did not change a thing. The code runs for me easily on the official release 1.11.0.

**How severe does this issue affect your experience of using Ray?**

- None: Just asking a question out of curiosity
- Low: It annoys or frustrates me for a moment.
- Medium: It contributes to significant difficulty to complete my task, but I can work around it.
- High: It blocks me to complete my task.

---

<div class="post-metadata">

**Author:** ![avnishn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/avnishn/32/1544_2.png) [@avnishn](https://discuss.ray.io/u/avnishn)\
**Post date:** [March 16, 2022, 12:57am UTC](https://discuss.ray.io/t/modulenotfound-ray-serve-generated/5361/2 "2022-03-16T00:57:45Z")

</div>

Is this from a fresh installation? It’s possible that your installation has been corrupted, while pulling from master. This is something that used to happen to me when I would install using the setup-dev.py script.

I’d recommend building from source by installing bazel and then from inside of the python directory, running `pip install -e .` I only have to rerun this command when the c++ ray bindings are updated (once every few weeks)
