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.
However, the same approach for Github Actions throws the error:
ModuleNotFoundError: No module named 'xxxx'
name: my_workflow on: push: branches: - master pull_request: branches: - master jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python 3.8 uses: actions/setup-python@v1 with: 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 pytest
I have tried to to set the PYTHONPATH to both
and the above, with no luck.
Solved! Solved! Go to Solution.
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 https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-pa....
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>"