Gitlab-ci不识别python
Gitlab-ci does not recognize python
我想 运行 我的 Jupyter notebooks 和我的管道。为此,我需要 runipy。要在 gitlab 运行ner 上安装 运行ipy,我需要 python。但是当我想要 运行 .gitlab-ci.yml 脚本时,它会卡在打印 python 版本,因为 python 无法识别。
.gitlab-ci.yml:
image: python:3.9
before_script:
- python -V
- pip install runipy
错误:
Running with gitlab-runner 13.3.1 (738bbe5a)
on JavaUnitTestRunner vr_SgzNd
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:01
Running on DESKTOP-DJVC49J...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Gitlab-Runner/builds/vr_SgzNd/0/I438220/pharma/.git/
Checking out 65a225c0 as pipeline...
git-lfs/2.9.2 (GitHub; windows amd64; go 1.12.7; git 0274d856)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:02
$ python -V
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\WINDOWS\TEMP\build_script377697220\script.ps1:195 char:1
+ python -V
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ERROR: Job failed: exit status 1
当我在 cmd 中尝试相同的命令时,一切正常。
根据您的日志,您正在使用 shell
执行器。这将在您的本地 shell 上 运行 命令,就像您自己一样。问题是 运行ner 不使用您的 OS 环境变量,因此您需要将 python
、git
等路径添加到 运行 ner的路径环境变量。
最好的方法是在 运行 用户 config.toml
的 [[runners]]
部分的 environment
变量中显式配置路径变量。 config.toml
文件可以位于 /etc/gitlab-runner/
、~/.gitlab-runner
或 /
根目录中。此 Whosebug thread shows how to do this. Please read Advanced Configurations 了解更多信息。
如果您想下载和使用自定义 docker 图片,例如 python:3.9
,您需要使用 Docker Executor.
我想 运行 我的 Jupyter notebooks 和我的管道。为此,我需要 runipy。要在 gitlab 运行ner 上安装 运行ipy,我需要 python。但是当我想要 运行 .gitlab-ci.yml 脚本时,它会卡在打印 python 版本,因为 python 无法识别。
.gitlab-ci.yml:
image: python:3.9
before_script:
- python -V
- pip install runipy
错误:
Running with gitlab-runner 13.3.1 (738bbe5a)
on JavaUnitTestRunner vr_SgzNd
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:01
Running on DESKTOP-DJVC49J...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Gitlab-Runner/builds/vr_SgzNd/0/I438220/pharma/.git/
Checking out 65a225c0 as pipeline...
git-lfs/2.9.2 (GitHub; windows amd64; go 1.12.7; git 0274d856)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:02
$ python -V
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\WINDOWS\TEMP\build_script377697220\script.ps1:195 char:1
+ python -V
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ERROR: Job failed: exit status 1
当我在 cmd 中尝试相同的命令时,一切正常。
根据您的日志,您正在使用 shell
执行器。这将在您的本地 shell 上 运行 命令,就像您自己一样。问题是 运行ner 不使用您的 OS 环境变量,因此您需要将 python
、git
等路径添加到 运行 ner的路径环境变量。
最好的方法是在 运行 用户 config.toml
的 [[runners]]
部分的 environment
变量中显式配置路径变量。 config.toml
文件可以位于 /etc/gitlab-runner/
、~/.gitlab-runner
或 /
根目录中。此 Whosebug thread shows how to do this. Please read Advanced Configurations 了解更多信息。
如果您想下载和使用自定义 docker 图片,例如 python:3.9
,您需要使用 Docker Executor.