用于科学计算的 Python 发行版和环境
如果这个问题太宽泛,我预先表示歉意。我来自 MATLAB 领域,对 Python 的经验相对较少。
在花了一些时间阅读了几个基于 Python 的科学计算环境和发行版之后,我觉得我仍然没有完全理解解决方案的前景或一些著名软件包之间的精确关系,包括:
更多具体来说:
- 上述软件包是否提供类似的功能?它们相辅相成吗?
- 其中任何一个的安装是否包括或需要安装任何一个 其他的?如果是,哪些包括或要求哪些?
不太重要的是,是否有任何其他类似于上面的包提供类似的功能?
提前致谢
I apologize upfront if this question is too broad. I come from the MATLAB world and have relatively little experience with Python.
After having spent some time reading about several Python-based environments and distributions for scientific computing, I feel that I still don't fully understand the landscape of solutions or the precise relationship between some notable packages, including:
More specifically:
- Do any of the above packages provide similar functionality? Do they complement each other?
- Does the installation of any of them include or require the installation of any of the
others? If so, which ones include or require which?
Less importantly, are there any other packages similar to the ones above that provide similar functionality?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Python 进行科学计算采用了一种简单的普通语言并附加了一堆模块,每个模块都实现了 MATLAB 功能的某些方面。因此,Python 科学编程的体验与 MATLAB 相比有点不连贯。然而,Python 作为一种语言要干净得多。就这样。
Python 中科学计算所需的基本模块是 Numpy、Matplotlib、SciPy,如果您要进行 3D 绘图,则 Mayavi/ VTK。这些模块都依赖于 Numpy。
Numpy 实现一种新的数组类型,其行为类似于 MATLAB 数组(即快速向量计算)。它还定义了一系列函数来执行这些计算,这些函数的名称通常与 MATLAB 中的类似函数相同。
Matplotlib 允许使用与 MATLAB 非常相似的命令进行二维绘图。 Matplotlib 还定义了 pylab,这是一个模块,只需一次导入即可将大多数 Numpy 和 Matplotlib 函数引入全局命名空间。这对于您不想键入大量名称空间前缀的快速/交互式脚本非常有用。
SciPy 是在 SciPy 框架下排列的对科学家有用的 Python 模块的集合。 SciPy 模块中提供了拟合例程。 Numpy 是 Scipy 的一部分。
Spyder 是一个桌面 IDE(基于 QT),它松散地尝试模拟 MATLAB IDE。它是 Python-XY 发行版的一部分。
IPython 提供增强的交互式 Python shell,对于尝试代码、运行脚本以及与结果交互非常有用。现在可以将其提供给 Web 界面以及传统控制台。它还嵌入在 Spyder IDE 中。
发行版
让所有这些模块在您的计算机上运行可能非常耗时,因此有一些发行版可以为您打包它们(以及许多其他模块)。
Python-XY、WinPython、Enthought 以及最近的Anaconda 都是包含所有核心模块的完整软件包发行版,尽管 Enthought 不随 Spyder 一起提供。
Sage 是另一种编程环境,它通过网络或命令行提供服务,并且还作为包含许多其他模块的完整包提供。传统上,它是基于 Linux 安装的 VMWare 映像。虽然你是在 Sage 环境中编写 Python,但它与普通的 Python 编程有点不同,它在某种程度上基于 Python 定义了自己的语言和方法。
如果您使用的是 Windows,我会安装 WinPython。它会安装您需要的一切,包括 Scipy 和 Spyder(恕我直言,这是 MATLAB for Python 的最佳替代品),并且由于它被设计为独立的,因此不会干扰您系统上可能安装的其他 Python 安装。如果您使用的是 OSX,Enthought 可能是最好的选择 - Spyder 可以使用 MacPorts 等单独安装。对于 Linux,您可以单独安装组件(Numpy、SciPy、Spyder、Matplotlib)。
我个人不喜欢“隐藏在幕后”使用 Python 的 Sage 方式,但您可能更喜欢这种方式。
Scientific computing with Python is taking a plain vanilla language and bolting on a bunch of modules, each of which implement some aspect of the functionality of MATLAB. As such the experience with Python scientific programming is a little incohesive c.f. MATLAB. However Python as a language is much cleaner. So it goes.
The basic necessary modules for scientific computing in Python are
Numpy
,Matplotlib
,SciPy
and if you are doing 3d plotting, thenMayavi/VTK
. These modules all depend on Numpy.Numpy Implements a new array type that behave similar to MATLAB arrays (i.e. fast vector calculations). It also defines a load of functions to do these calculations which are usually named the same as similar functions in MATLAB.
Matplotlib Allows for 2d plotting with very similar commands to MATLAB. Matplotlib also defines pylab, which is a module that - with a single import - brings most of the Numpy and Matplotlib functions into the global namespace. This is useful for rapid/interactive scripting where you don't want to be typing lots of namespace prefixes.
SciPy is a collection of Python modules arranged under the SciPy umbrella that are useful to scientists. Fitting routines are supplied in SciPy modules. Numpy is part of Scipy.
Spyder is a desktop IDE (based on QT) that loosely tries to emulate MATLAB IDE. It is part of the Python-XY distribution.
IPython provides an enhanced interactive Python shell which is useful for trying out code and running your scripts and interacting with the results. It can now be served to a web interface as well as the traditional console. It is also embedded in the Spyder IDE.
Distributions
Getting all these modules running on your computer can be time consuming and so there are a few distributions that package them (plus many other modules) up for you.
Python-XY, WinPython, Enthought and more recently Anaconda are all full package distributions that include all the core modules, although Enthought does not come with Spyder.
Sage is another programming environment which is served over the web or via a command line and also comes as a full package including lots of other modules. Traditionally it came as a VMWare image based on an install of Linux. Although you are writing Python in the Sage environment, it's a little different to ordinary Python programming, it kind of defines its own language and methodology based on Python.
If you are using Windows I would install WinPython. It installs everything that you need including Scipy and Spyder (which is the best replacement for MATLAB for Python IMHO) and because it is designed to be standalone it will not interfere with other installs of Python you may have on your system. If you are on OSX, Enthought is probably the best way to go - Spyder can be installed separately using e.g. MacPorts. For Linux you can install the components (Numpy, SciPy, Spyder, Matplotlib) separately.
I personally don't like the Sage way of working with Python 'hidden under the hood' but you may prefer that.
关于问题的不太重要的部分:
Regarding the less important part of the question:
此链接可能有用: https://www.cfa.harvard.edu/~ebresser/ python/
这是哈佛大学一位天体物理学家的页面。它给出了在 OS-X 上从 ITT-VIS IDL 切换到 python 的人的观点(但大多数技巧也适用于其他操作系统)。
编辑:该页面似乎已被删除。对于科学家/工程师来说,另一个很好的 Python 介绍在这个文档中(大 PDF 警告):http: //stsdas.stsci.edu/perry/pydatatut.pdf
希望这个不要被下架!
This link may be usefull: https://www.cfa.harvard.edu/~ebresser/python/
It's the page of an astrophysicist at Harvard. It gives the point of view of someone switching from ITT-VIS IDL to python, on OS-X (but most tips also work on other operating systems).
EDIT: It seems the page was taken down. An alternative good introduction to python for a scientist/engineer is in this document (big PDF warning): http://stsdas.stsci.edu/perry/pydatatut.pdf
Hope this one will not be taken down!