为什么应通过二进制软件包安装NumPy? [英] Why should NumPy be installed via a binary package?

查看:79
本文介绍了为什么应通过二进制软件包安装NumPy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 NumPy文档:

在大多数情况下,在系统上安装NumPy的最佳方法是使用适用于您操作系统的可安装二进制程序包.

In most use cases the best way to install NumPy on your system is by using an installable binary package for your operating system.

但是为什么不能使用pip轻松安装它呢?

But why can't it be installed just as easily using pip?

据我了解,NumPy需要根据目标机器来编译除纯Python之外的东西.这是如何运作的?二进制软件包中是否包含C源文件和C编译器?还是它包含所有预编译的二进制文件,而只是根据操作系统选择合适的二进制文件进行安装?

As I understand it, NumPy needs to compile something other than pure Python according to the target machine. How does this work? Does the binary package contain C source files and a C compiler? Or does it contain all the pre-compiled binaries, and just chooses the proper ones to install based on the operating system?

推荐答案

pip包仅包含numpy源代码发行版,其中包括用C编写的扩展,因此,要构建它,您需要具有一个可用的C编译器(并且当然不会与numpy源一起预打包).您还需要一个LAPACK库,如果从源代码构建它,则可能还需要FORTRAN 77编译器.

The pip package just contains the numpy source distribution which includes extensions written in C, so in order to build it you'll need to have a working C compiler (and this certainly doesn't come pre-packaged with the numpy source). You'll also need a LAPACK library which, if you build it from source, will probably also require a FORTRAN 77 compiler.

通过pip安装numpy的难易程度在很大程度上取决于您正在使用的环境.通常来说,如果您使用的是Linux或OSX,则很容易设置必要的工具链.由于编译器支持的状态要差得多,通常Windows用户往往会遇到最多的问题,因此通常的建议是从二进制发行版进行安装. Anaconda 分发和

How easy it is to install numpy via pip will depend greatly on what environment you're working in. Generally speaking it's pretty easy to set up the necessary toolchain if you're using Linux or OSX. It's usually Windows users that tend to suffer the most problems, due to the much poorer state of compiler support, so the usual recommendation is to install from a binary distribution. The Anaconda distribution and Christoph Gohlke's pre-built binaries are probably the two most popular options.

如果您是Windows用户,并且感到特别冒险/受虐,还可以从

If you're a Windows user and you're feeling particularly adventurous/masochistic, there are also instructions for compiling numpy and scipy from source here.

这篇关于为什么应通过二进制软件包安装NumPy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆