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

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

Could not open requirements file in github actions

问题

但不断出现以下错误

  1. /opt/hostedtoolcache/Python/3.10.12/x64/bin/python -m pip install -r requirements.txt
  2. 错误:无法打开要求文件:[Errno 2] 没有那个文件或目录:'requirements.txt'
  3. 错误: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 工作流文件

  1. name: testing
  2. on: [push,pull_request]
  3. run-name: running tests for searchenginepy
  4. jobs:
  5. build:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - name: setup python
  9. uses: actions/setup-python@v4
  10. with:
  11. python-version: '3.10' # 安装所需的 Python 版本
  12. - name: Install dependencies
  13. uses: py-actions/py-dependency-install@v4
  14. with:
  15. path: "requirements.txt"
  16. - name: run tests # 运行 main.py
  17. working-directory: tests
  18. run: python -m unittest discover

我尝试过

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

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

英文:

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

but keep getting this error

  1. /opt/hostedtoolcache/Python/3.10.12/x64/bin/python -m pip install -r requirements.txt
  2. ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
  3. 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

  1. name: testing
  2. on: [push,pull_request]
  3. run-name: running tests for searchenginepy
  4. jobs:
  5. build:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - name: setup python
  9. uses: actions/setup-python@v4
  10. with:
  11. python-version: '3.10' # install the python version needed
  12. - name: Install dependencies
  13. uses: py-actions/py-dependency-install@v4
  14. with:
  15. path: "requirements.txt"
  16. - name: run tests # run main.py
  17. working-directory: tests
  18. 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

  1. name: testing
  2. on: [push, pull_request]
  3. run-name: 运行搜索引擎测试
  4. jobs:
  5. build:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - uses: actions/checkout@v3
  9. - name: 设置 Python
  10. uses: actions/setup-python@v4
  11. with:
  12. python-version: '3.10' # 安装所需的 Python 版本
  13. - name: 安装依赖项
  14. uses: py-actions/py-dependency-install@v4
  15. with:
  16. path: "requirements.txt"
  17. - name: 运行测试 # 运行 main.py
  18. working-directory: tests
  19. run: python -m unittest discover
英文:

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

  1. name: testing
  2. on: [push,pull_request]
  3. run-name: running tests for searchenginepy
  4. jobs:
  5. build:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - uses: actions/checkout@v3
  9. - name: setup python
  10. uses: actions/setup-python@v4
  11. with:
  12. python-version: '3.10' # install the python version needed
  13. - name: Install dependencies
  14. uses: py-actions/py-dependency-install@v4
  15. with:
  16. path: "requirements.txt"
  17. - name: run tests # run main.py
  18. working-directory: tests
  19. 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:

确定