无法在GitHub操作中打开要求文件。

huangapple go评论70阅读模式
英文:

Could not open requirements file in github actions

问题

但不断出现以下错误

/opt/hostedtoolcache/Python/3.10.12/x64/bin/python -m pip install -r requirements.txt
错误:无法打开要求文件:[Errno 2] 没有那个文件或目录:'requirements.txt'
错误:ERROR: Action failed during dependency installation attempt with error: The process '/opt/hostedtoolcache/Python/3.10.12/x64/bin/python' failed with exit code 1

你可以查看我的目录结构这里
和 GitHub 工作流文件

name: testing
on: [push,pull_request]
run-name: running tests for searchenginepy
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10' # 安装所需的 Python 版本
          
      - name: Install dependencies
        uses: py-actions/py-dependency-install@v4
        with:
              path: "requirements.txt"
          
      - name: run tests # 运行 main.py
        working-directory: tests
        run: python -m unittest discover

我尝试过

> pip install .
> pip install -r .github/workflows/requirements.txt

我也不确定关于 unittest 目录,因为它需要在 tests 文件夹中运行。

英文:

I am trying to setup a github workflow (first time)

but keep getting this error

/opt/hostedtoolcache/Python/3.10.12/x64/bin/python -m pip install -r requirements.txt
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
Error: ERROR: Action failed during dependency installation attempt with error: The process '/opt/hostedtoolcache/Python/3.10.12/x64/bin/python' failed with exit code 1

you can view my director structure here
and github workflow file

name: testing
on: [push,pull_request]
run-name: running tests for searchenginepy
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10' # install the python version needed
          
      - name: Install dependencies
        uses: py-actions/py-dependency-install@v4
        with:
              path: "requirements.txt"
          
      - name: run tests # run main.py
        working-directory: tests
        run: python -m unittest discover
          

I have tried

> pip install .
> pip install -r .github/workflows/requirements.txt

I am also not sure about the unittest directory because that needs to be run in the tests folder

答案1

得分: 1

请只添加检出步骤 - uses: actions/checkout@v3

name: testing
on: [push, pull_request]
run-name: 运行搜索引擎测试
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: 设置 Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10' # 安装所需的 Python 版本
          
      - name: 安装依赖项
        uses: py-actions/py-dependency-install@v4
        with:
          path: "requirements.txt"
          
      - name: 运行测试 # 运行 main.py
        working-directory: tests
        run: python -m unittest discover
英文:

Please just add checkout step - uses: actions/checkout@v3

name: testing
on: [push,pull_request]
run-name: running tests for searchenginepy
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10' # install the python version needed
          
      - name: Install dependencies
        uses: py-actions/py-dependency-install@v4
        with:
              path: "requirements.txt"
          
      - name: run tests # run main.py
        working-directory: tests
        run: python -m unittest discover

huangapple
  • 本文由 发表于 2023年7月12日 22:40:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76671774.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定