Gitlab CI Runner 出现错误 "cannot import name 'run_cli' from 'robot'"
Getting error "cannot import name 'run_cli' from 'robot'" with Gitlab CI Runner
我有一个像 python -m robot --include staging_lp_items
这样的机器人命令,它在我的系统中 运行 非常完美。
在服务器计算机中尝试使用 GitLab 运行ner(作为阶段脚本)运行 时,显示此错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/site-packages/robot/__main__.py", line 25, in <module>
from robot import run_cli
ImportError: cannot import name 'run_cli' from 'robot' (/usr/local/lib/python3.9/site-packages/robot/__init__.py)
我还要确保安装机器人,return 主脚本之前的 pip list
和 robot
安装在服务器环境上以及 [=19= 中的其他要求] 文件。
这是系统配置:
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
GitLab Yaml:
stages:
- build
- build_branch
- test
variables:
REGISTRY_IMAGE: ${CI_REGISTRY}/qa/${CI_PROJECT_NAME}
GIT_IMAGE: ${CI_REGISTRY}/qa/${CI_PROJECT_NAME}
build:
image: docker:latest
stage: build
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- echo image name $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
- docker build -t $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
- docker push $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
rules:
- when: manual
build_branch:
image: docker:latest
stage: build_branch
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- echo project image is ${GIT_IMAGE}
- docker build --build-arg CI_COMMIT_REF_NAME=master -t $GIT_IMAGE:$CI_COMMIT_REF_NAME .
- docker push $GIT_IMAGE:$CI_COMMIT_REF_NAME
rules:
- when: manual
allow_failure: true
run_test:
image: $GIT_IMAGE:$CI_COMMIT_REF_NAME
stage: test
script:
- cat /etc/os-release
- chmod +x ./.deploy/run-test.sh
- ./.deploy/run-test.sh
rules:
- when: manual
allow_failure: false
有 3 个阶段, build
和 build_branch
工作正常。最后一个是我遇到问题的主要阶段。这个阶段将 运行 (eval) run-test.sh
有一个我之前提到的简单 python-robotframework 命令。
Python版本:3.9
Docker 文件
FROM python:3.9
ARG CI_COMMIT_REF_NAME=master
COPY . .
RUN pip install [Repository]
RUN pip install -r requirements.txt
您的requirementst.txt无效。 https://pypi.org/project/robot/, while the library that you want to use is named robotframework
https://pypi.org/project/robotframework/.
你有 robot
在您的 requirements.txt 中将 robot
重命名为 robotframework
。
我有一个像 python -m robot --include staging_lp_items
这样的机器人命令,它在我的系统中 运行 非常完美。
在服务器计算机中尝试使用 GitLab 运行ner(作为阶段脚本)运行 时,显示此错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/site-packages/robot/__main__.py", line 25, in <module>
from robot import run_cli
ImportError: cannot import name 'run_cli' from 'robot' (/usr/local/lib/python3.9/site-packages/robot/__init__.py)
我还要确保安装机器人,return 主脚本之前的 pip list
和 robot
安装在服务器环境上以及 [=19= 中的其他要求] 文件。
这是系统配置:
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
GitLab Yaml:
stages:
- build
- build_branch
- test
variables:
REGISTRY_IMAGE: ${CI_REGISTRY}/qa/${CI_PROJECT_NAME}
GIT_IMAGE: ${CI_REGISTRY}/qa/${CI_PROJECT_NAME}
build:
image: docker:latest
stage: build
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- echo image name $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
- docker build -t $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
- docker push $REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
rules:
- when: manual
build_branch:
image: docker:latest
stage: build_branch
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- echo project image is ${GIT_IMAGE}
- docker build --build-arg CI_COMMIT_REF_NAME=master -t $GIT_IMAGE:$CI_COMMIT_REF_NAME .
- docker push $GIT_IMAGE:$CI_COMMIT_REF_NAME
rules:
- when: manual
allow_failure: true
run_test:
image: $GIT_IMAGE:$CI_COMMIT_REF_NAME
stage: test
script:
- cat /etc/os-release
- chmod +x ./.deploy/run-test.sh
- ./.deploy/run-test.sh
rules:
- when: manual
allow_failure: false
有 3 个阶段, build
和 build_branch
工作正常。最后一个是我遇到问题的主要阶段。这个阶段将 运行 (eval) run-test.sh
有一个我之前提到的简单 python-robotframework 命令。
Python版本:3.9
Docker 文件
FROM python:3.9
ARG CI_COMMIT_REF_NAME=master
COPY . .
RUN pip install [Repository]
RUN pip install -r requirements.txt
您的requirementst.txt无效。 https://pypi.org/project/robot/, while the library that you want to use is named robotframework
https://pypi.org/project/robotframework/.
robot
在您的 requirements.txt 中将 robot
重命名为 robotframework
。