我是新来的码头工人,所以我很抱歉这么简单的问题。
我正在构建一个docker容器,它构建在一个基于ubuntu:vivid image的图像之上。 在容器中执行脚本时,出现错误:
exec: "python": executable file not found in $PATH
我该怎么解决?
当我试图在Docker文件中运行apt-get install python
时:
FROM my_image # based on ubuntu:vivid
RUN apt-get update && \
apt-get install -y python3
ENV PATH /:$PATH
COPY file.py /
CMD ["python", "file.py", "-h"]
我得到:
WARNING: The following packages cannot be authenticated!
libexpat1 libffi6 libmagic1 libmpdec2 libssl1.0.0 libpython3.4-minimal
mime-support libsqlite3-0 libpython3.4-stdlib python3.4-minimal
python3-minimal python3.4 libpython3-stdlib dh-python python3 file
E: There are problems and -y was used without --force-yes
The command '/bin/sh -c apt-get update && apt-get install -y python3' returned a non-zero code: 100
make: *** [image] Error 1
编辑:添加的Dockerfile内容
您正在安装python3,然后使用python的可执行文件,我遇到了同样的问题,我已经使用python3解决了这个问题。
尝试更改Dockerfile的最后一行:
而不是
CMD ["python", "file.py", "-h"]
尝试:
CMD ["python3", "file.py", "-h"]
对于某些Linux发行版,您也有类似的问题:“Why am I getting authentication errors for packages from an Ubuntu repository?”
在所有情况下,安装新软件包的通常命令顺序是:
OP Ela报告in the comments:
相关问题 更多 >
编程相关推荐