You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
6.7 KiB

4 years ago
  1. Building and installing SciPy
  2. +++++++++++++++++++++++++++++
  3. See https://www.scipy.org/Installing_SciPy/
  4. .. Contents::
  5. INTRODUCTION
  6. ============
  7. It is *strongly* recommended that you use either a complete scientific Python
  8. distribution or binary packages on your platform if they are available, in
  9. particular on Windows and Mac OS X. You should not attempt to build SciPy if
  10. you are not familiar with compiling software from sources.
  11. Recommended distributions are:
  12. - Enthought Canopy (https://www.enthought.com/products/canopy/)
  13. - Anaconda (https://www.anaconda.com)
  14. - Python(x,y) (http://python-xy.github.io/)
  15. - WinPython (https://winpython.github.io/)
  16. The rest of this install documentation summarizes how to build Scipy. Note
  17. that more extensive (and possibly more up-to-date) build instructions are
  18. maintained at http://scipy.org/scipylib/building/index.html
  19. PREREQUISITES
  20. =============
  21. SciPy requires the following software installed for your platform:
  22. 1) Python__ 2.7 or >= 3.4
  23. __ http://www.python.org
  24. 2) NumPy__ >= 1.8.2
  25. __ http://www.numpy.org/
  26. 3) For building from source: setuptools__
  27. __ https://github.com/pypa/setuptools
  28. 4) If you want to build the documentation: Sphinx__ >= 1.2.1
  29. __ http://sphinx-doc.org/
  30. 5) If you want to build SciPy master or other unreleased version from source
  31. (Cython-generated C sources are included in official releases):
  32. Cython__ >= 0.23.4
  33. __ http://cython.org/
  34. Windows
  35. -------
  36. Compilers
  37. ~~~~~~~~~
  38. There are two ways to build Scipy on Windows:
  39. 1. Use Intel MKL, and Intel compilers or ifort + MSVC. This is what Anaconda
  40. and Enthought Canopy use.
  41. 2. Use MSVC + gfortran with OpenBLAS. This is how the SciPy Windows wheels are
  42. built.
  43. Mac OS X
  44. --------
  45. Compilers
  46. ~~~~~~~~~
  47. It is recommended to use gcc or clang, both work fine. Gcc is available for
  48. free when installing Xcode, the developer toolsuite on Mac OS X. You also
  49. need a fortran compiler, which is not included with Xcode: you should use a
  50. recent gfortran from an OS X package manager (like Homebrew).
  51. Please do NOT use gfortran from `hpc.sourceforge.net <http://hpc.sourceforge.net>`_,
  52. it is known to generate buggy scipy binaries.
  53. Blas/Lapack
  54. ~~~~~~~~~~~
  55. Mac OS X includes the Accelerate framework: it should be detected without any
  56. intervention when building SciPy.
  57. Linux
  58. -----
  59. Most common distributions include all the dependencies. You will need to
  60. install a BLAS/LAPACK (all of ATLAS, OpenBLAS, MKL work fine) including
  61. development headers, as well as development headers for Python itself. Those
  62. are typically packaged as python-dev
  63. INSTALLING SCIPY
  64. ================
  65. For the latest information, see the web site:
  66. https://www.scipy.org
  67. Development version from Git
  68. ----------------------------
  69. Use the command::
  70. git clone https://github.com/scipy/scipy.git
  71. cd scipy
  72. git clean -xdf
  73. python setup.py install --user
  74. Documentation
  75. -------------
  76. Type::
  77. cd scipy/doc
  78. make html
  79. From tarballs
  80. -------------
  81. Unpack ``SciPy-<version>.tar.gz``, change to the ``SciPy-<version>/``
  82. directory, and run::
  83. pip install . -v --user
  84. This may take several minutes to half an hour depending on the speed of your
  85. computer.
  86. TESTING
  87. =======
  88. To test SciPy after installation (highly recommended), execute in Python
  89. >>> import scipy
  90. >>> scipy.test()
  91. To run the full test suite use
  92. >>> scipy.test('full')
  93. If you are upgrading from an older SciPy release, please test your code for any
  94. deprecation warnings before and after upgrading to avoid surprises:
  95. $ python -Wd -c my_code_that_shouldnt_break.py
  96. Please note that you must have version 1.0 or later of the Pytest test
  97. framework installed in order to run the tests. More information about Pytest is
  98. available on the website__.
  99. __ https://pytest.org/
  100. COMPILER NOTES
  101. ==============
  102. You can specify which Fortran compiler to use by using the following
  103. install command::
  104. python setup.py config_fc --fcompiler=<Vendor> install
  105. To see a valid list of <Vendor> names, run::
  106. python setup.py config_fc --help-fcompiler
  107. IMPORTANT: It is highly recommended that all libraries that scipy uses (e.g.
  108. BLAS and ATLAS libraries) are built with the same Fortran compiler. In most
  109. cases, if you mix compilers, you will not be able to import Scipy at best, have
  110. crashes and random results at worst.
  111. UNINSTALLING
  112. ============
  113. When installing with ``python setup.py install`` or a variation on that, you do
  114. not get proper uninstall behavior for an older already installed Scipy version.
  115. In many cases that's not a problem, but if it turns out to be an issue, you
  116. need to manually uninstall it first (remove from e.g. in
  117. ``/usr/lib/python3.4/site-packages/scipy`` or
  118. ``$HOME/lib/python3.4/site-packages/scipy``).
  119. Alternatively, you can use ``pip install . --user`` instead of ``python
  120. setup.py install --user`` in order to get reliable uninstall behavior.
  121. The downside is that ``pip`` doesn't show you a build log and doesn't support
  122. incremental rebuilds (it copies the whole source tree to a tempdir).
  123. TROUBLESHOOTING
  124. ===============
  125. If you experience problems when building/installing/testing SciPy, you
  126. can ask help from scipy-user@python.org or scipy-dev@python.org mailing
  127. lists. Please include the following information in your message:
  128. NOTE: You can generate some of the following information (items 1-5,7)
  129. in one command::
  130. python -c 'from numpy.f2py.diagnose import run; run()'
  131. 1) Platform information::
  132. python -c 'import os, sys; print(os.name, sys.platform)'
  133. uname -a
  134. OS, its distribution name and version information
  135. etc.
  136. 2) Information about C,C++,Fortran compilers/linkers as reported by
  137. the compilers when requesting their version information, e.g.,
  138. the output of
  139. ::
  140. gcc -v
  141. g77 --version
  142. 3) Python version::
  143. python -c 'import sys; print(sys.version)'
  144. 4) NumPy version::
  145. python -c 'import numpy; print(numpy.__version__)'
  146. 5) ATLAS version, the locations of atlas and lapack libraries, building
  147. information if any. If you have ATLAS version 3.3.6 or newer, then
  148. give the output of the last command in
  149. ::
  150. cd scipy/Lib/linalg
  151. python setup_atlas_version.py build_ext --inplace --force
  152. python -c 'import atlas_version'
  153. 7) The output of the following commands
  154. ::
  155. python INSTALLDIR/numpy/distutils/system_info.py
  156. where INSTALLDIR is, for example, /usr/lib/python3.4/site-packages/.
  157. 8) Feel free to add any other relevant information.
  158. For example, the full output (both stdout and stderr) of the SciPy
  159. installation command can be very helpful. Since this output can be
  160. rather large, ask before sending it into the mailing list (or
  161. better yet, to one of the developers, if asked).
  162. 9) In case of failing to import extension modules, the output of
  163. ::
  164. ldd /path/to/ext_module.so
  165. can be useful.