首页 > 解决方案 > Github 操作、pip 和 PATH

问题描述

我正在尝试在 Github Actions 工作流程中使用通过 pip 安装的包。在文档中,我找到了一个代码示例,它做的事情类似于我想要的:

steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install flake8 pytest
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
    - name: Lint with flake8
      run: |
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

但我尝试使用运行工作流程,我在下面看到一个错误:

/home/runner/work/_temp/cd52f069-5af0-49d4-832f-b750b17fdb7a.sh: line 2: flake8: command not found
Error: Process completed with exit code 127.

我应该如何修改代码示例以使其工作?

标签: githubpipcontinuous-integrationgithub-actions

解决方案


推荐阅读