我正在使用带有自定义DockerFile的Visual Studio Code Remote-容器扩展。它基于https://github.com/microsoft/vscode-dev-containers/blob/master/containers/python-3/.devcontainer/Dockerfile,但使用了不同的基本映像,因此不会尝试从requirements.txt进行pip安装。
当我在vscode中构建容器时,将PostCreateCommand设置为“ python --version”,在开发容器终端输出中会出现以下错误:
Run: docker exec -w /workspaces/media-classifier dd5e552b4f113ecf74504cc6d3aed3ca1727b4a172645515392c4632b7c45b81 /bin/sh -c python --version
/bin/sh: 1: python: not found
postCreateCommand "python --version" failed.
我尝试使用标准python3容器和python3 anaconda容器对PostCreateCommand(python --version)使用相同的设置值,并且它们都成功输出了python版本。
我还尝试将PostCreateCommand设置为以下值,这些值都会产生相同的“未找到”错误:
pip --version 康达--version
启动容器后,我可以成功使用python,pip和conda,因此可以肯定地安装它们。
Dockerfile
FROM microsoft/cntk:2.6-cpu-python3.5
# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install git procps lsb-release \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
devcontainer.json
{
"name": "CNTK Python3.5",
"context": "..",
"dockerFile": "Dockerfile",
// Uncomment the next line if you want to publish any ports.
// "appPort": [],
// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "python --version",
"extensions": [
"ms-python.python",
"neuron.neuron-ipe"
],
"settings": {
"python.pythonPath": "/opt/conda/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
}
}
我希望PostCreateCommand能够成功执行并输出安装在当时处于活动状态的anaconda环境中的python版本。
答案 0 :(得分:0)
您正在尝试在安装python
时运行python3
尝试运行
python3 --version