# Dvc exp run and pythonpath

**URL:** <https://discuss.dvc.org/t/dvc-exp-run-and-pythonpath/1654>\
**Category:** Questions\
**Created:** [May 5, 2023, 3:25pm UTC](https://discuss.dvc.org/t/dvc-exp-run-and-pythonpath/1654 "2023-05-05T15:25:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonTroitskii](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@AntonTroitskii](https://discuss.dvc.org/u/AntonTroitskii)\
**Post date:** [May 5, 2023, 3:25pm UTC](https://discuss.dvc.org/t/dvc-exp-run-and-pythonpath/1654/1 "2023-05-05T15:25:33Z")

</div>

I tried to run experiments by comand:

dvc exp run --run-all

How I understand execute files are located in my case in _.dvc\tmp\exps\tmp105umt89\src\stages_.  
But there are _src.utils.files_ module in my directory and this files tree copy to _.dvc\tmp\exps\tmp105umt89_ folder. I am using VS code and I use options \*Terminal \> Integrated \> Env to add the workspace folder to pythonpath. It works good with _dvc repro_ but it’s not working with _dvc run exp_.

The main reason is that I can’t use relative import in python modulus which run as scripts. These experiments folders don’t have constant pathes.

So, how can I run the exps in this case? Does the dvc have an option to add path to pythonpath localy?

---

<div class="post-metadata">

**Author:** ![pmrowla](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pmrowla](https://discuss.dvc.org/u/pmrowla)\
**Post date:** [May 8, 2023, 5:59am UTC](https://discuss.dvc.org/t/dvc-exp-run-and-pythonpath/1654/2 "2023-05-08T05:59:47Z")

</div>

In the latest DVC release you can use the `-C/--copy-paths` option to add your python module directories so they are copied into the temporary execution workspace like:

```auto
dvc exp run --queue --copy-paths src/utils

```

See: [exp run](https://dvc.org/doc/command-reference/exp/run#-C)

Alternatively, you could add your entire `src` directory as the stage dependency (which would also make DVC copy the directory into the execution workspace)

---

<div class="post-metadata">

**Author:** ![AntonTroitskii](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@AntonTroitskii](https://discuss.dvc.org/u/AntonTroitskii)\
**Post date:** [May 12, 2023, 6:16am UTC](https://discuss.dvc.org/t/dvc-exp-run-and-pythonpath/1654/3 "2023-05-12T06:16:12Z")

</div>

> [@pmrowla](#):
>
> Alternatively, you could add your entire `src` directory as the stage dependency (which would also make DVC copy the directory into the execution workspace)

Initially, I have these scripts files in my stage deps and this files copy to my execution workspace how I understand. I can see these scripy files in my tmp directory as I described before. But sys.path doesn’t have this directory when the copy to tmp dir.

To clarify my point. Initially I have a worksace dir which is in sys.path because I use specific settind of my vscode so the workspace is added to my sys.path.  
If I understand correctly the tree of workspace files are copied to something like that .dvc\tmp\exps\tmp\105umt89 for each experimetns. And this directory is not in my sys.path so the mains sripts (preapare.py, train.py, …) don’t see needed modules.

I solved my issue by coping my scripts in src dir on the top level. But interesting that this approach doesn’t use in the dvc course. And the course’s stages files run from src/stages. I didn’t run the course files. but when I try to use this approach I have problem.
