【发布时间】:2023-03-24 18:40:02
【问题描述】:
我正在尝试使用这个 dockerfile 在 Ubuntu14.04 上安装 python3.7 和 pip:
FROM ubuntu:14.04
RUN apt update -y && apt install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa && apt -y update
RUN apt-get install -y python3.7
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.4 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
RUN apt install -y python3-pip
构建并运行:
$ docker build -t doc .
$ docker run -it --rm doc bash
在容器中更改 python 配置:选择选项 2
$ update-alternatives --config python3
然后运行 pip3 会返回:
Traceback (most recent call last):
File "/usr/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
ubuntu18.04 上的相同步骤可以正常工作。有什么建议吗?
【问题讨论】:
标签: python pip ubuntu-14.04