python3 --version shows quot;NameError: name #39;python3#39; is not definedquot;(python3 --version 显示“NameError: name python3 is not defined)
问题描述
当我们输入时
python3 --version (or --V)
它应该向我们展示python的版本对吗?
it is supposed to show us the version of the python right?
但是,当我这样做时,我收到以下错误:
However, when I do this I get the following error:
NameError: name 'python3' is not defined
NameError: name 'python3' is not defined
我尝试使用安装pip时也是这种情况
This is also the case when I tried to install the pip by using
>>> python3 get-pip.py
File "<stdin>", line 1
python3 get-pip.py
^
SyntaxError: invalid syntax
推荐答案
python3 不是 Python 语法,它是 Python 二进制文件本身,你运行到交互式解释器的东西.
python3 is not Python syntax, it is the Python binary itself, the thing you run to get to the interactive interpreter.
您将 命令行 与 Python 提示符混淆了.打开控制台 (Windows) 或终端 (Linux、Mac),您可以使用 dir 或 ls 从命令行浏览文件系统.
You are confusing the command line with the Python prompt. Open a console (Windows) or terminal (Linux, Mac), the same place you'd use dir or ls to explore your filesystem from the command line.
如果您在 >>> 或 In [number]: 提示符处键入,则说明您来错地方了,那就是 Python 解释器本身和它只需要 Python 语法.如果您从命令行启动 Python 提示符,则退出此时并返回命令行.如果您从 IDLE 或在 IDE 中启动解释器,则需要将终端或控制台作为单独的程序打开.
If you are typing at a >>> or In [number]: prompt you are in the wrong place, that's the Python interpreter itself and it only takes Python syntax. If you started the Python prompt from a command line, exit at this point and go back to the command line. If you started the interpreter from IDLE or in an IDE, then you need to open a terminal or console as a separate program.
人们经常混淆 Python 语法的其他程序;其中每一个实际上都是在命令提示符下运行的程序:
Other programs that people often confuse for Python syntax; each of these is actually a program to run in your command prompt:
python、python2.7、python3.5等pip或pip3虚拟环境ipythoneasy_installdjango-adminconda烧瓶scrapysetup.py-- 这是您需要使用python setup.py [...]运行的脚本.- 以上任何一项连同
sudo.
python,python2.7,python3.5, etc.piporpip3virtualenvipythoneasy_installdjango-admincondaflaskscrapysetup.py-- this is a script you need to run withpython setup.py [...].- Any of the above together with
sudo.
根据您安装的工具和库以及您要执行的操作,可能会有更多变化.
with many more variations possible depending on what tools and libraries you have installed and what you are trying to do.
如果给定参数,您将得到 SyntaxError 异常,但根本原因是相同的:
If given arguments, you'll get a SyntaxError exception instead, but the underlying cause is the same:
>>> pip install foobar
File "<stdin>", line 1
pip install foobar
^
SyntaxError: invalid syntax
这篇关于python3 --version 显示“NameError: name 'python3' is not defined"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:python3 --version 显示“NameError: name 'python3' is not defined"
基础教程推荐
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 求两个直方图的卷积 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 包装空间模型 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
