Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't install a python package & use it in a GitHub Action

I have a GitHub Repo with a simple GitHub Actions workflow:

name: CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: echo Hello, world!
    - name: Run a multi-line script
      run: |
        echo Add other actions to build,
        echo test, and deploy your project.
        pip install twine
        twine --help

When I run it, it installs twine, but fails to run it, saying the command is not found:

...
Successfully installed Pygments-2.5.2 bleach-3.1.0 certifi-2019.11.28 chardet-3.0.4 docutils-0.15.2 idna-2.8 pkginfo-1.5.0.1 readme-renderer-24.0 requests-2.22.0 requests-toolbelt-0.9.1 setuptools-42.0.2 six-1.13.0 tqdm-4.40.0 twine-1.15.0 urllib3-1.25.7 webencodings-0.5.1
/home/runner/work/_temp/1643cb1d-8b12-4aa8-8e1d-bd5bba60fd5b.sh: line 4: twine: command not found

How can I get this to work?

Thanks in advance.

I am already aware of existing GitHub actions that use twine, they don't do what I want. I also know that I can fork an action and modify it, but what I really want to know is, if I can run echo hello world why can't I run pip install some-pkg; some-pkg ... ?

It does not seem to be a path problem. I've tried using python -m twine in place of twine. I tried running a find command to find all files on the machine that have twine in their name (it didn't find any).

like image 996
Dan Tenenbaum Avatar asked Oct 27 '25 03:10

Dan Tenenbaum


2 Answers

Not sure if this will fix the problem, but it's highly recommended anyway. Use the official actions/setup-python action to prepare the environment.

    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-python@v1
    - name: Run a one-line script
      run: echo Hello, world!
    - name: Run a multi-line script
      run: |
        echo Add other actions to build,
        echo test, and deploy your project.
        pip install twine
        twine --help
like image 189
peterevans Avatar answered Oct 29 '25 01:10

peterevans


Got this to work:

pip install --user twine
python -m twine --help

Or instead of using python -m, specifying the path:

~/.local/bin/twine --help
like image 37
Dan Tenenbaum Avatar answered Oct 29 '25 00:10

Dan Tenenbaum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!