[英]Using "python --version" command bringing up error message
I have Python 3.7.1 on my Windows 10 PC.我的 Windows 10 PC 上有 Python 3.7.1。 I want to install Pandas and firstly need to do some checks to see if I have everything required.我想安装 Pandas,首先需要做一些检查,看看我是否拥有所需的一切。 I tried typing the following to double check the Python version:我尝试输入以下内容来仔细检查 Python 版本:
python --version
but it keeps spitting out the error:但它不断吐出错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined
According to the Pandas website, if this error occurs it's because I need to type it into Python Shell.根据 Pandas 网站,如果发生此错误,那是因为我需要将其输入到 Python Shell 中。 But that's what I'm doing... I know I'm probably missing something really obvious, but I'd really appreciate any hints and tips for this very basic problem...但这就是我正在做的......我知道我可能遗漏了一些非常明显的东西,但我真的很感激这个非常基本问题的任何提示和技巧......
Thanks!谢谢!
You shouldn't be entering python --version
in a Python shell.您不应该在 Python shell 中输入python --version
。 Enter it in the cmd.exe shell.在 cmd.exe shell 中输入它。
You probably get this Error:您可能会收到此错误:
The answer from RasikhJ is right, except you have to use brackets in your Python3 version: RasikhJ 的答案是正确的,只是您必须在 Python3 版本中使用方括号:
import sys
print (sys.version)
If you just want to know your Python version, then use the command line:如果您只想知道您的 Python 版本,请使用命令行:
Use the sys package:使用 sys 包:
import sys
print sys.version
Or use the platform module:或者使用平台模块:
import platform
print platform.python_version()
You should try py --version
in cmd
.您应该在cmd
尝试py --version
。
C:\Users\XYZ>py --version
Python 3.8.5
Try py --version
in cmd.在 cmd 中尝试py --version
。
C:\Users\XYZ>py --version
Python 3.8.3
I did the same command/entries in Miniforge Prompt(mambaforge) and had No errors or problems what so ever.. If I use Python 3.10 (64-bit) I get nothing but error messages on just about everything.我在 Miniforge Prompt(mambaforge) 中执行了相同的命令/条目并且没有任何错误或问题。 I'm not a dictionary on commands but Miniforge Prompt(mambaforge) has never given me any problems.我不是命令字典,但 Miniforge Prompt(mambaforge) 从来没有给我任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.