Set pythonpath in Github Actions, running on Ubuntu.

I am relying on modules in my project for which I would like to set append a PYTHONPATH.

Working locally I would do it like this and it works.

export PYTHONPATH=$PYTHONPATH:/home/<user>/<code>

However, the same approach for Github Actions throws the error:

ModuleNotFoundError: No module named 'xxxx'


name: my_workflow

- master
- master

runs-on: ubuntu-latest

- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: set pythonpath
run: |
# this does not work.
export PYTHONPATH=$PYTHONPATH:/home/runner/work/<repo_name>
- name: Test with pytest
run: |
pip install pytest

pwd returns


I have tried to to set the PYTHONPATH to both 


and the above, with no luck.

Please help!

Each step in actions runs in its own process so exporting in a shell is not going to translate across steps.  To update the path for a downstream step you need to use the add-path workflow command

1 Like

command: echo “::add-path::/path/to/dir” will pepend a directory to the system PATH variable for all subsequent actions in the current job. But look at your code, are you searching ‘set-env’?

echo "::set-env name=PYTHONPATH::home/runner/work/<repo_name>"
1 Like

Hello i keep having the same error. can you give me a step by set on how i solve this.