简体   繁体   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. 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. But while I am using in gitlab-ci.yml, I am not able to upgrade python and pip.但是当我在 gitlab-ci.yml 中使用时,我无法升级 python 和 pip。 It shows still the previous pip version.它仍然显示以前的 pip 版本。 Please need your support.请需要您的支持。

There is a gitlab stage I am using by name of 'pytest':我正在使用一个名为“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 pipeline log as follows: 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)

Here we can see still the python version is 3.5.2 but I am trying to use python 3.7 from docker image.在这里,我们仍然可以看到 python 版本是 3.5.2,但我正在尝试使用 docker 图像中的 python 3.7。 Need your valuable input.需要您的宝贵意见。 How can I upgrade docker image python to 3.7 and PIP accordingly in GitLab CICD?如何在 ZCF0A6993A4B526850302726C 中相应地将 docker 映像 python 升级到 3.7 和 PIP?

Thanks in advance.提前致谢。

As requested by Kristian while tried with: apt-get update -yqq its throwing an error regarding access and I do not have permission to change the access as well.正如克里斯蒂安在尝试使用时所要求的: 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

If I try your snipped I get the correct python and pip version:如果我尝试你的剪断,我会得到正确的 python 和 pip 版本:

stages:
  - pytest

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

Output: 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)

It seems your image is somehow messed up as python:3.7 should download the 3.7.10-buster Image.看起来你的图像有点混乱,因为python:3.7应该下载3.7.10-buster图像。

What happens if you change the image to the tag image: python:3.7.10-buster ?如果将图像更改为标签image: python:3.7.10-buster会发生什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM