python:即使在 GitLab CICD 中安装后也找不到命令

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

在 GitLab CICD 中,我使用的是 Google 云 sdk 镜像

gcr.io/google.com/cloudsdktool/cloud-sdk:latest
,因为我必须在
gcloud
中使用
before_script
。该图像没有附带 python,我还需要运行一些脚本。

before_script
中,我使用以下命令在Google云sdk映像上安装了python:

server_update_dev:
  stage: server_update_dev
  image: gcr.io/google.com/cloudsdktool/cloud-sdk:latest
  before_script:
    - gcloud config set project abc
    - apt-get -yq update
    - apt-get -yq install python3.10
  script:
    - python test.py

但我收到错误

python: command not found
。我在这里犯了什么错误?如何确保
gcloud
python
命令都可用。

gitlab gcloud cicd
1个回答
0
投票

错误是您认为

python
命令正在运行
python3
。 为了使其成为可能,您可以安装
python-is-python3
软件包:

apt install python-is-python3

这应该有效

script:
- python test.py

或明确使用

python3

  script:
  - python3 test.py

如果您有更多 docker 方面的问题,您可以在本地重现它:

docker run -it gcr.io/google.com/cloudsdktool/cloud-sdk:latest /bin/bash
© www.soinside.com 2019 - 2024. All rights reserved.