|
1 | | -***************************** |
2 | | -Building and installing NumPy |
3 | | -***************************** |
4 | | - |
5 | | -Binary installers |
6 | | -================= |
| 1 | +**************** |
| 2 | +Installing NumPy |
| 3 | +**************** |
7 | 4 |
|
8 | 5 | In most use cases the best way to install NumPy on your system is by using an |
9 | | -installable binary package for your operating system. |
10 | | - |
11 | | -Windows |
12 | | -------- |
13 | | - |
14 | | -Good solutions for Windows are, `Enthought Canopy |
15 | | -<https://www.enthought.com/products/canopy/>`_, `Anaconda |
16 | | -<http://continuum.io/downloads.html>`_ (which both provide binary installers |
17 | | -for Windows, OS X and Linux) and `Python (x, y) <http://www.pythonxy.com>`_. |
18 | | -Both of these packages include Python, NumPy and many additional packages. |
19 | | - |
20 | | -A lightweight alternative is to download the Python |
21 | | -installer from `www.python.org <http://www.python.org>`_ and the NumPy |
22 | | -installer for your Python version from the Sourceforge `download site |
23 | | -<http://sourceforge.net/projects/numpy/files/NumPy`_. |
24 | | - |
25 | | -The NumPy installer includes binaries for different CPU's (without SSE |
26 | | -instructions, with SSE2 or with SSE3) and installs the correct one |
27 | | -automatically. If needed, this can be bypassed from the command line with :: |
28 | | - |
29 | | - numpy-<1.y.z>-superpack-win32.exe /arch nosse |
30 | | - |
31 | | -or ``sse2`` or ``sse3`` instead of ``nosse``. |
32 | | - |
33 | | -Linux |
34 | | ------ |
35 | | - |
36 | | -All major distributions provide packages for NumPy. These are usually |
37 | | -reasonably up-to-date, but sometimes lag behind the most recent NumPy release. |
38 | | - |
39 | | -Mac OS X |
40 | | --------- |
41 | | - |
42 | | -Universal binary installers for NumPy are available from the `download site |
43 | | -<http://sourceforge.net/projects/numpy/files/NumPy`_, and wheel packages |
44 | | -from PyPi. With a recent version of `pip`<https://pip.pypa.io/en/latest/>`_ |
45 | | -this will give you a binary install (from the wheel packages) compatible with |
46 | | -at python.org Python, Homebrew and MacPorts:: |
47 | | - |
48 | | - pip install numpy |
49 | | - |
50 | | - |
51 | | -.. _building-from-source: |
52 | | - |
53 | | -Building from source |
54 | | -==================== |
55 | | - |
56 | | -A general overview of building NumPy from source is given here, with detailed |
57 | | -instructions for specific platforms given seperately. |
58 | | - |
59 | | -Prerequisites |
60 | | -------------- |
61 | | - |
62 | | -Building NumPy requires the following software installed: |
63 | | - |
64 | | -1) Python 2.6.x, 2.7.x, 3.2.x or newer |
65 | | - |
66 | | - On Debian and derivatives (Ubuntu): python, python-dev (or python3-dev) |
67 | | - |
68 | | - On Windows: the official python installer at |
69 | | - `www.python.org <http://www.python.org>`_ is enough |
70 | | - |
71 | | - Make sure that the Python package distutils is installed before |
72 | | - continuing. For example, in Debian GNU/Linux, installing python-dev |
73 | | - also installs distutils. |
74 | | - |
75 | | - Python must also be compiled with the zlib module enabled. This is |
76 | | - practically always the case with pre-packaged Pythons. |
77 | | - |
78 | | -2) Compilers |
79 | | - |
80 | | - To build any extension modules for Python, you'll need a C compiler. |
81 | | - Various NumPy modules use FORTRAN 77 libraries, so you'll also need a |
82 | | - FORTRAN 77 compiler installed. |
83 | | - |
84 | | - Note that NumPy is developed mainly using GNU compilers. Compilers from |
85 | | - other vendors such as Intel, Absoft, Sun, NAG, Compaq, Vast, Porland, |
86 | | - Lahey, HP, IBM, Microsoft are only supported in the form of community |
87 | | - feedback, and may not work out of the box. GCC 4.x (and later) compilers |
88 | | - are recommended. |
89 | | - |
90 | | -3) Linear Algebra libraries |
91 | | - |
92 | | - NumPy does not require any external linear algebra libraries to be |
93 | | - installed. However, if these are available, NumPy's setup script can detect |
94 | | - them and use them for building. A number of different LAPACK library setups |
95 | | - can be used, including optimized LAPACK libraries such as ATLAS, MKL or the |
96 | | - Accelerate/vecLib framework on OS X. |
97 | | - |
98 | | -Basic Installation |
99 | | ------------------- |
100 | | - |
101 | | -To install NumPy run:: |
102 | | - |
103 | | - python setup.py install |
104 | | - |
105 | | -To perform an in-place build that can be run from the source folder run:: |
106 | | - |
107 | | - python setup.py build_ext --inplace |
108 | | - |
109 | | -The NumPy build system uses ``distutils`` and ``numpy.distutils``. |
110 | | -``setuptools`` is only used when building via ``pip`` or with ``python |
111 | | -setupegg.py``. Using ``virtualenv`` should work as expected. |
112 | | - |
113 | | -*Note: for build instructions to do development work on NumPy itself, see |
114 | | -:ref:`development-environment`*. |
115 | | - |
116 | | -.. _parallel-builds: |
117 | | - |
118 | | -Parallel builds |
119 | | -~~~~~~~~~~~~~~~ |
120 | | - |
121 | | -From NumPy 1.10.0 on it's also possible to do a parallel build with:: |
122 | | - |
123 | | - python setup.py build -j 4 install --prefix $HOME/.local |
124 | | - |
125 | | -This will compile numpy on 4 CPUs and install it into the specified prefix. |
126 | | -to perform a parallel in-place build, run:: |
127 | | - |
128 | | - python setup.py build_ext --inplace -j 4 |
129 | | - |
130 | | -The number of build jobs can also be specified via the environment variable |
131 | | -``NPY_NUM_BUILD_JOBS``. |
132 | | - |
133 | | - |
134 | | -FORTRAN ABI mismatch |
135 | | --------------------- |
136 | | - |
137 | | -The two most popular open source fortran compilers are g77 and gfortran. |
138 | | -Unfortunately, they are not ABI compatible, which means that concretely you |
139 | | -should avoid mixing libraries built with one with another. In particular, if |
140 | | -your blas/lapack/atlas is built with g77, you *must* use g77 when building |
141 | | -numpy and scipy; on the contrary, if your atlas is built with gfortran, you |
142 | | -*must* build numpy/scipy with gfortran. This applies for most other cases |
143 | | -where different FORTRAN compilers might have been used. |
144 | | - |
145 | | -Choosing the fortran compiler |
146 | | -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
147 | | - |
148 | | -To build with g77:: |
149 | | - |
150 | | - python setup.py build --fcompiler=gnu |
151 | | - |
152 | | -To build with gfortran:: |
153 | | - |
154 | | - python setup.py build --fcompiler=gnu95 |
155 | | - |
156 | | -For more information see:: |
157 | | - |
158 | | - python setup.py build --help-fcompiler |
159 | | - |
160 | | -How to check the ABI of blas/lapack/atlas |
161 | | -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
162 | | - |
163 | | -One relatively simple and reliable way to check for the compiler used to build |
164 | | -a library is to use ldd on the library. If libg2c.so is a dependency, this |
165 | | -means that g77 has been used. If libgfortran.so is a a dependency, gfortran |
166 | | -has been used. If both are dependencies, this means both have been used, which |
167 | | -is almost always a very bad idea. |
168 | | - |
169 | | -Disabling ATLAS and other accelerated libraries |
170 | | ------------------------------------------------ |
171 | | - |
172 | | -Usage of ATLAS and other accelerated libraries in Numpy can be disabled |
173 | | -via:: |
174 | | - |
175 | | - BLAS=None LAPACK=None ATLAS=None python setup.py build |
176 | | - |
177 | | - |
178 | | -Supplying additional compiler flags |
179 | | ------------------------------------ |
180 | | - |
181 | | -Additional compiler flags can be supplied by setting the ``OPT``, |
182 | | -``FOPT`` (for Fortran), and ``CC`` environment variables. |
183 | | - |
184 | | - |
185 | | -Building with ATLAS support |
186 | | ---------------------------- |
187 | | - |
188 | | -Ubuntu |
189 | | -~~~~~~ |
190 | | - |
191 | | -You can install the necessary package for optimized ATLAS with this command:: |
| 6 | +pre-built package for your operating system. |
192 | 7 |
|
193 | | - sudo apt-get install libatlas-base-dev |
| 8 | +Please see http://scipy.org/install.html for links to available options. |
194 | 9 |
|
| 10 | +For instructions on building for source package, see |
| 11 | +:doc:`building`. This information is useful mainly for advanced users. |
0 commit comments