Python 使用Shell Executor在CI-CD的GitLab配置yml文件中激活Conda环境
我想在Gitlab CI-CD进程中激活conda环境。 我在本地计算机(UNIX)上向Shell Executor注册了Gitlab runner(v13.10),与我的工作笔记本电脑不同 我试图通过repo中存在的环境yml文件激活conda环境,但失败并显示未找到conda命令 我编辑了.gitlab-ci.yml文件,如下所示:Python 使用Shell Executor在CI-CD的GitLab配置yml文件中激活Conda环境,python,anaconda,gitlab,conda,gitlab-ci-runner,Python,Anaconda,Gitlab,Conda,Gitlab Ci Runner,我想在Gitlab CI-CD进程中激活conda环境。 我在本地计算机(UNIX)上向Shell Executor注册了Gitlab runner(v13.10),与我的工作笔记本电脑不同 我试图通过repo中存在的环境yml文件激活conda环境,但失败并显示未找到conda命令 我编辑了.gitlab-ci.yml文件,如下所示: stages: - build build stage: stage: build before_script: - whi
stages:
- build
build stage:
stage: build
before_script:
- which python
- export PIP_CACHE_DIR="/opt/cache/pip"
- conda env create -f environment.yml
- source activate env_work
script:
- echo "Building"
- cd parent_dir
- python main.py new_studies/first_study
artifacts:
paths:
- out/
only:
- master
我面临的问题是它抛出了一个错误:CONDA命令未找到
Running with gitlab-runner 13.10.0 (5421146)
on rig ci runner gZzdceA
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on rig-machine...
Getting source from Git repository
00:04
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/gZzdceA/0/company/gg/product/repo/.git/
Checking out 883ga36 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ export PIP_CACHE_DIR="/opt/cache/pip"
$ conda env create -f environment.yml
bash: line 120: conda: command not found
Cleaning up file based variables
00:00
ERROR: Job failed: exit status 1
我提到了各种问题,如和。此外,我还尝试将anaconda路径添加到bash文件中,作为环境路径变量。但我不确定我是否做对了
我的问题是:
Conda通常通过
.bashrc
添加到路径中(默认配置中包含Conda init
中的代码)。可能需要让shell会话在登录模式下运行(-l
标志),或者手动添加一行来初始化Conda(例如,/etc/profile.d/Conda.sh
)。还请注意,conda activate env_work
优先于source activate env_work
——后者的语法是conda v4.6之前的语法。