# ModuleNotFoundError for custom env import when num\_workers \> 0

**URL:** <https://discuss.ray.io/t/modulenotfounderror-for-custom-env-import-when-num-workers-0/3950>\
**Category:** Ray Core\
**Created:** [October 27, 2021, 4:16pm UTC](https://discuss.ray.io/t/modulenotfounderror-for-custom-env-import-when-num-workers-0/3950 "2021-10-27T16:16:55Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![miguelinux314](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/miguelinux314/32/5683_2.png) [@miguelinux314](https://discuss.ray.io/u/miguelinux314)\
**Post date:** [January 31, 2024, 4:10pm UTC](https://discuss.ray.io/t/modulenotfounderror-for-custom-env-import-when-num-workers-0/3950/6 "2024-01-31T16:10:29Z")

</div>

@klausk55 I think I run into a similar problem.

Remote workers would fail to deserialize data from modules imported from within the project. In my case, it was due to the deserialization process being attempted from the workers’ initial directory instead of the working dir. I could fix this issue by running a worker\_process\_setup\_hook function before submitting tasks to the workers. This function would perform an os.chdir so that the (relative) imports work well:

```auto
ray.init(runtime_env={"worker_process_setup_hook": logging_setup_func})

```

I got the idea from [Execute function on each worker process in the cluster](https://discuss.ray.io/t/execute-function-on-each-worker-process-in-the-cluster/12314)

I didn’t find a explicit solution to my problem, so maybe this will help others as well.

---

_[View the full topic](https://discuss.ray.io/t/modulenotfounderror-for-custom-env-import-when-num-workers-0/3950)._
