Py学习  »  Python

当我尝试python3版本时,它不能作为命令工作

learner • 4 年前 • 611 次点击  

我有以下docker文件:

FROM ubuntu:latest

RUN apt-get update \
  && apt-get install -y python3-pip python3-dev \
  && cd /usr/local/bin \
  && ln -s /usr/bin/python3 python3 \
  && pip3 install --upgrade pip
USER root
COPY scripts scripts
RUN ls
RUN pwd
RUN chmod +x ./scripts/functional_test_cli/baft.py
COPY tests tests
RUN pip3 install Pytest
RUN pip3 install pytest-json-report
RUN pip3 install Tavern
RUN pip3 install allure-pytest
RUN pip3 install pytest-pythonpath
RUN pip install --upgrade setuptools
RUN which python

RUN python3 version
CMD ["python3", "./scripts/functional_test_cli/baft.py"]

因此,当运行python3版本时,会抛出以下错误:

python: can't open file 'version': [Errno 2] No such file or directory

我有什么遗漏吗?为什么python3不被识别为命令?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/51183
 
611 次点击  
文章 [ 3 ]  |  最新文章 4 年前
Abhishek Kumar
Reply   •   1 楼
Abhishek Kumar    4 年前

您可以检查python3是否安装了

python3 --version

python3 -V

但这个错误是因为你的码头恶魔找不到你的 bafi.py公司 文件

Skylar Liang
Reply   •   2 楼
Skylar Liang    4 年前

如果您想检查安装了哪个版本的python,它应该是 python3 --version . 如果执行时不带破折号,则表示要运行名为“version”的脚本。

occidere
Reply   •   3 楼
occidere    4 年前

换成 python3 --version python3 -V

$ python3 --version
Python 3.7.3

$ python3 -V
Python 3.7.3


我想没有命令只是 version 在蟒蛇身上。

(它可能看起来像文件引用。感谢@cricket(007)

$ python3 version
python3: can't open file 'version': [Errno 2] No such file or directory