博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
我已经安装了哪个版本的Python?
阅读量:2382 次
发布时间:2019-05-10

本文共 2692 字,大约阅读时间需要 8 分钟。

本文翻译自:

I have to run a Python script on a Windows server. 我必须在Windows服务器上运行Python脚本。 How can I know which version of Python I have, and does it even really matter? 我怎么知道我拥有哪个版本的Python,它真的很重要吗?

I was thinking of updating to the latest version of Python. 我当时想更新到最新版本的Python。


#1楼

参考:


#2楼

In a Python IDE, just copy and paste in the following code and run it (the version will come up in the output area): 在Python IDE中,只需复制并粘贴以下代码并运行它(版本将显示在输出区域中):

import sysprint(sys.version)

#3楼

You can get the version of Python by using the following command 您可以使用以下命令获取Python的版本

python --version

You can even get the version of any package installed in venv using pip freeze as: 您甚至可以使用pip freeze Frozen获得venv中安装的任何软件包的版本,如下所示:

pip freeze | grep "package name"

Or using the Python interpreter as: 或将Python解释器用作:

In [1]: import djangoIn [2]: django.VERSIONOut[2]: (1, 6, 1, 'final', 0)

#4楼

Although the question is "which version am I using?", this may not actually be everything you need to know. 尽管问题是“我正在使用哪个版本?”,但这实际上可能并不是您需要知道的所有内容。 You may have other versions installed and this can cause problems, particularly when installing additional modules. 您可能安装了其他版本,这可能会导致问题,尤其是在安装其他模块时。 This is my rough-and-ready approach to finding out what versions are installed: 这是我了解安装了哪些版本的粗略方法:

updatedb                  # Be in root for thislocate site.py            # All installations I've ever seen have this

The output for a single Python installation should look something like this: 单个Python安装的输出应如下所示:

/usr/lib64/python2.7/site.py/usr/lib64/python2.7/site.pyc/usr/lib64/python2.7/site.pyo

Multiple installations will have output something like this: 多个安装将输出如下内容:

/root/Python-2.7.6/Lib/site.py/root/Python-2.7.6/Lib/site.pyc/root/Python-2.7.6/Lib/site.pyo/root/Python-2.7.6/Lib/test/test_site.py/usr/lib/python2.6/site-packages/site.py/usr/lib/python2.6/site-packages/site.pyc/usr/lib/python2.6/site-packages/site.pyo/usr/lib64/python2.6/site.py/usr/lib64/python2.6/site.pyc/usr/lib64/python2.6/site.pyo/usr/local/lib/python2.7/site.py/usr/local/lib/python2.7/site.pyc/usr/local/lib/python2.7/site.pyo/usr/local/lib/python2.7/test/test_site.py/usr/local/lib/python2.7/test/test_site.pyc/usr/local/lib/python2.7/test/test_site.pyo

#5楼

Use 使用

python -V

or 要么

python --version

NOTE: Please note that the "V" in the python -V command is capital V. python -v (small "v") will launch Python in verbose mode. 注意:请注意python -V命令中的“ V”为大写python -v (小“ v”)将以详细模式启动Python。


#6楼

For me, opening CMD and running 对我来说,打开CMD并运行

py

will show something like 将显示类似

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.

转载地址:http://zbexb.baihongyu.com/

你可能感兴趣的文章
字符集研究之不同字符集的转换方式
查看>>
参观广东省博物馆
查看>>
C#调用C库的注意事项
查看>>
游戏杆编程心得二:如何判断按钮的有效按下
查看>>
一个应用程序无法启动错误的解决过程
查看>>
除虫记——有关WindowsAPI文件查找函数的一次压力测试
查看>>
Incredibuild导入key的方式
查看>>
跨平台C++开源代码的两种常用编译方式
查看>>
VC和MATLAB混合开发需要注意的一个问题
查看>>
成都一日游
查看>>
清明节太原两日游
查看>>
Java学习笔记(一)
查看>>
关于IT公司招聘的一个思考
查看>>
C#调用C++接口返回字符串的做法
查看>>
未能返回新代码元素错误的解决
查看>>
软件研发部门的基础设施
查看>>
华为研发的成功之道
查看>>
略论研发评审的必要性
查看>>
元旦修灯记
查看>>
软体和软件的区别
查看>>