Python中是否有sessionInfo()等效项? [英] Is there a sessionInfo() equivalent in Python?
问题描述
通常我使用R,并且经常在要使内容可复制时使用sessionInfo()
.这样做的原因是,我想让人们知道我正在使用的所有内容的版本,安装/加载的软件包以及所使用的操作系统等,因此非常清楚.
Normally I use R, and often when wanting to make things reproduicible I use sessionInfo()
. The reason for this is that I like to let people know what version of everything I am using and what packages I have installed/loaded and what OS I am on etc, so that its quite clear.
sessionInfo
返回R的版本,处理器类型(例如32/64位x86),操作系统,语言环境详细信息以及已加载的软件包.
sessionInfo
returns the version of R, the processor type (e.g. 32/64 bit x86), the operating system, the locale details, and which packages have been loaded.
我是python的新手,想知道Python是否有等效功能?我希望在iPython笔记本中使用它...
I am new to python and wondered if there is an equivalent for Python? I'm hoping to use it in an iPython Notebook...
推荐答案
以下内容将使您脱颖而出:
The following will make you part there :
In [1]: import IPython
In [2]: print IPython.sys_info()
{'codename': 'Work in Progress',
'commit_hash': '4dd36bf',
'commit_source': 'repository',
'default_encoding': 'UTF-8',
'ipython_path': '/Users/matthiasbussonnier/ipython/IPython',
'ipython_version': '2.0.0-dev',
'os_name': 'posix',
'platform': 'Darwin-11.4.2-x86_64-i386-64bit',
'sys_executable': '/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python',
'sys_platform': 'darwin',
'sys_version': '2.7.6 (default, Nov 28 2013, 17:25:22) \n[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]'}
否则,没有标准的方法来获取导入模块的版本. pip freeze
会为您节省机器上模块的大多数已安装版本:
Otherwise there is no standard way to get the version of imported modules. pip freeze
will wive you most of installed version of modules on your machine though:
In [3]: !pip freeze
Cython==0.20dev
Django==1.4.2
Fabric==1.7.0
Flask==0.9
Flask-Cache==0.10.1
Flask-Markdown==0.3
Flask-SQLAlchemy==0.16
Jinja2==2.7.1
Logbook==0.6.0
...
这是我们认为应先在python中解决的问题,然后再使IPython成为魔术"来帮助它.这经常被要求,我们还没有找到应该做的和要求是什么的妥协.
This is something we think should be solved in python before making IPython 'magics' that help with it. This is often requested and we haven't yes find a compromise of what should be done and what would be the requirements.
这篇关于Python中是否有sessionInfo()等效项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!