在作业Gitlab中“poetry install”后找不到python包

问题描述 投票:0回答:1

我正在尝试使用“pytest”在 GitLab 中运行作业测试。 在项目中我使用诗歌,但在命令“诗歌安装”之后看不到已安装的库。错误:

pytest: command not found

我的*-gitlab-ci.yml:

stages:
  - testing

test_job:
  image: python:3.11-slim
  stage: testing
  script:
    - 'apt-get update && apt-get install -y curl jq && curl -sSL https://install.python- 
       poetry.org | python3'
    - 'PATH="$PATH:/root/.local/bin/"'
    - 'poetry config virtualenvs.create false && poetry install'
    - 'pytest tests'

在 Job 中,所有需要的东西都已安装,我稍后检查“poetry --version”/“python --version”,它们已就位,但 Python 库(pytest)给出错误。

我的 pyproject.toml:

[tool.poetry]
name = "pytestwithtesting"
version = "0.1.0"
description = "educational project"
authors = ["avtest <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8"
pytest = "^8.2.2"
pyhamcrest = "^2.1.0"
cards = "^2.0.0"
allure-pytest = "^2.13.5"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

且项目结构较小:

pytestwithtesting-|
                  |- /tests
                  |-.gitlab-ci.yml
                  |- REAMDE.md
                  |- poetry.toml
                  |- pyproject.toml

请告诉我我可能错过了什么?

python-3.x pytest gitlab-ci python-poetry
1个回答
0
投票

source .. activate
为我工作

- pip install -q poetry
- python -m poetry install --no-interaction
- source `poetry env info --path`/bin/activate
© www.soinside.com 2019 - 2024. All rights reserved.