Activating conda environment during gitlab CI(在 gitlab CI 期间激活 conda 环境)
问题描述
我的 .gitlab-ci.yml
文件如下所示:
My .gitlab-ci.yml
file looks like this:
anomalydetector:
image: continuumio/miniconda:4.7.10
stage: build
tags:
- docker
script:
- conda env create -f environment.yml
- conda activate my-env
- pytest tests/.
在 Gitlab 上,这项工作开始正常,并且读取了日志
On Gitlab, this job starts fine, and the logs read
$ conda env create -f environment.yml
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
==> WARNING: A newer version of conda exists. <==
current version: 4.7.10
latest version: 4.7.11
好的,所以我使用的是 4.4 之后的 conda
版本,所以 conda activate
应该可以工作.但是,作业失败并显示以下内容:
Ok, so I'm using a conda
version later than 4.4, so conda activate
should work. However, the job fails with the following:
# To activate this environment, use
#
# $ conda activate my-env
#
# To deactivate an active environment, use
#
# $ conda deactivate
$ conda activate my-env
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
然后我尝试编辑我的 .gitlab-ci.yml
文件以便有一个命令
I have then tried editing my .gitlab-ci.yml
file so that there is a command
conda init bash
然后得到消息
==> For changes to take effect, close and re-open your current shell. <==
如何在 gitlab CI 进程中激活我的 conda 环境?
How can I activate my conda environment in the gitlab CI process?
推荐答案
conda init
触及 .bashrc
文件.要重新初始化 shell,您可以获取它:
conda init
touches the .bashrc
file. To reinitialize the shell you can source it:
- conda create --name myenv
- conda init bash
- source ~/.bashrc # <- !!!
- conda activate myenv
我猜这是否比 source activate myenv
更好或更差是一个单独的讨论.
Whether this is better or worse than source activate myenv
is a separate discussion, I guess.
这篇关于在 gitlab CI 期间激活 conda 环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 gitlab CI 期间激活 conda 环境
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 沿轴计算直方图 2022-01-01