Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python module not found with sudo in github action

I wanted to use coveragepy combine to seperate .coverage files into one.

For that I installed python and the coverage module via pip, afterwards then running this command. python -m coverage combine .coverage-*. That should work and does, but aparrently requires either root or for the user to own the directory. So I decided to use sudo within the github action, since I read that it’s passwordless.

But when running the installed module with sudo in front of the command it says /usr/bin/python: No module named coverage.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is the part of my workflow responsible for the actions explained above:

      - name: Set up Python
        uses: actions/setup-python@v3
        with:
          python-version: "3.10"

      - name: Install coverage
        run: |
          python -m pip install --upgrade pip
          pip install coverage

      - name: Listing all items in data directory (Testing)
        run: ls -Al ./docker/data/coverage

      - name: Merge coverage reports
        working-directory: ./docker/data/coverage
        run: sudo python -m coverage combine .coverage-*

running the sudo python -m coverage combine .coverage-* on my local machine works just fine.

Is there any way I can get python to recognise that, that module exists and is installed or is there maybe any other workaround I could use?

>Solution :

I suspect pip is installing coverage to the user directory. If you must run the command with sudo, try running the pip install with sudo as well.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading