# Run each actor in its own virutal environment

**URL:** <https://discuss.ray.io/t/run-each-actor-in-its-own-virutal-environment/4316>\
**Category:** Ray Core\
**Created:** [December 1, 2021, 1:57pm UTC](https://discuss.ray.io/t/run-each-actor-in-its-own-virutal-environment/4316 "2021-12-01T13:57:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiranbi](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@shiranbi](https://discuss.ray.io/u/shiranbi)\
**Post date:** [December 1, 2021, 1:57pm UTC](https://discuss.ray.io/t/run-each-actor-in-its-own-virutal-environment/4316/1 "2021-12-01T13:57:25Z")

</div>

I want each actor to run with their own dependencies.

I am running in a closed environment where doing pip install at runtime is not an option  
In the end I plan to run in static ray cluster on kubernetes [Deploying a Static Ray Cluster on Kubernetes — Ray v1.8.0](https://docs.ray.io/en/latest/cluster/kubernetes-manual.html#ray-k8s-static)  
right now I am running my tests on my ubuntu server directly

To do this, I though about using runtime env feature and setting in env\_vars the VIRTUAL\_ENV variable.

I created a virtual env where I installed ray[Default] and numpy (which my actor uses)  
runtime\_env = {  
“env\_vars”: {  
“VIRTUAL\_ENV”: “path to virtual env”},  
}  
I did echo $VIRTUAL\_ENV in my pycharm terminal to make sure I am copying the correct path

when I call  
counter\_actor = Counter.options(runtime\_env=runtime\_env).remote()  
I get  
(raylet) [2021-12-01 15:26:45,652 E 21303 21303] agent\_manager.cc:134: Not all required Ray dependencies for the runtime\_env feature were found. To install the required dependencies, please run `pip install 'ray[default]'`.

I tried passing the runtime\_env in ray\_init (just to make sure it has nothing to do with the actor) and got the same error with the addition of  
(raylet) [2021-12-01 15:53:25,881 E 22621 22621] worker\_pool.cc:566: [Eagerly] Couldn’t create a runtime environment for job 01000000.

I am sure ray is installed in my virtual environment as I see the ray folder (with dashboard inside so I know it installed the full installation)

How can I run each actor with its own virtual environment?

---

<div class="post-metadata">

**Author:** ![architkulkarni](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/architkulkarni/32/10_2.png) [@architkulkarni](https://discuss.ray.io/u/architkulkarni)\
**Post date:** [December 1, 2021, 10:54pm UTC](https://discuss.ray.io/t/run-each-actor-in-its-own-virutal-environment/4316/2 "2021-12-01T22:54:02Z")

</div>

Hi, can you see if the error message goes away with the `aiohttp` downgrade workaround proposed in [[Bug] Ray master fails to start dashboard as a result of new aiohttp version (3.8) · Issue #19940 · ray-project/ray · GitHub](https://github.com/ray-project/ray/issues/19940)?

Your approach should then work; the Ray worker will be started with the environment variables that are set.

If you are willing to use `conda`, another option is to preinstall your desired conda environments on each node, and then pass the name of the environment in the `conda` field of the runtime environment. (No need to pass any environment variables if using this approach.)

---

<div class="post-metadata">

**Author:** ![shiranbi](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@shiranbi](https://discuss.ray.io/u/shiranbi)\
**Post date:** [December 2, 2021, 12:02pm UTC](https://discuss.ray.io/t/run-each-actor-in-its-own-virutal-environment/4316/3 "2021-12-02T12:02:42Z")

</div>

it solved the problem  
also had to use PYTHONPATH instead VIRTUAL\_ENV
