簡體   English   中英

無法使用 GitLab CICD 中的 docker 映像將 python 版本升級到 3.7

[英]Not able to upgrade python version to 3.7 using docker image in GitLab CICD

I am trying to use docker image in GitLab CICD pipeline above Python 3.5 version(as it is not supported any more and deprecated from Jan 2021), ie trying to upgrade to Python 3.7 using docker image. 但是當我在 gitlab-ci.yml 中使用時,我無法升級 python 和 pip。 它仍然顯示以前的 pip 版本。 請需要您的支持。

我正在使用一個名為“pytest”的 gitlab 階段:

pytest:
  stage: pytest
  image: python:3.7
  script:
    - python --version
    - python3 --version
    - pip3 --version
    - pip3 install --upgrade pip
    - which aws || pip3 install awscli
    - which eb || pip3 install awsebcli
    - python3 --version
    - pip3 --version

GitLab流水線日志如下:

$ python --version
Python 2.7.12
$ python3 --version
Python 3.5.2
$ pip3 --version
pip 20.3.4 from /var/opt/gitlab-runner/.local/lib/python3.5/site-packages/pip (python 3.5)
$ pip3 install --upgrade pip
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /var/opt/gitlab-runner/.local/lib/python3.5/site-packages (20.3.4)
Collecting pip
  Using cached pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
  Using cached pip-20.3.3-py2.py3-none-any.whl (1.5 MB)
$ which aws || pip3 install awscli
/usr/local/bin/aws
$ which eb || pip3 install awsebcli
/var/opt/gitlab-runner/.local/bin/eb
$ python3 --version
Python 3.5.2
$ pip3 --version
pip 20.3.4 from /var/opt/gitlab-runner/.local/lib/python3.5/site-packages/pip (python 3.5)

在這里,我們仍然可以看到 python 版本是 3.5.2,但我正在嘗試使用 docker 圖像中的 python 3.7。 需要您的寶貴意見。 如何在 ZCF0A6993A4B526850302726C 中相應地將 docker 映像 python 升級到 3.7 和 PIP?

提前致謝。

正如克里斯蒂安在嘗試使用時所要求的: apt-get update -yqq它引發了有關訪問的錯誤,我也無權更改訪問權限。

$ apt-get update -yqq
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
Cleaning up file based variables
00:01
ERROR: Job failed: exit status 1

如果我嘗試你的剪斷,我會得到正確的 python 和 pip 版本:

stages:
  - pytest

pytest:
  image: python:3.7
  stage: pytest
  script:
    - python --version
    - python3 --version
    - pip3 --version

Output:

$ python --version
Python 3.7.10
$ python3 --version
Python 3.7.10
$ pip3 --version
pip 21.0.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

看起來你的圖像有點混亂,因為python:3.7應該下載3.7.10-buster圖像。

如果將圖像更改為標簽image: python:3.7.10-buster會發生什么?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM