211

It is possible to install NumPy with pip using pip install numpy.

Is there a similar possibility with SciPy? (Doing pip install scipy does not work.)


Update

The package SciPy is now available to be installed with pip!

nbro
  • 15,395
  • 32
  • 113
  • 196
Olivier Verdier
  • 46,998
  • 29
  • 98
  • 90
  • 3
    You might like to reconsider the accepted answer (maybe to knoxxs's?). I don't think installing via git should be the preferred method! :) – Andy Hayden Sep 26 '13 at 18:26
  • 11
    It is relevant again, because the last few versions can't simply `pip install` – erikbstack Nov 20 '14 at 12:40

15 Answers15

218

Prerequisite:

sudo apt-get install build-essential gfortran libatlas-base-dev python-pip python-dev
sudo pip install --upgrade pip

Actual packages:

sudo pip install numpy
sudo pip install scipy

Optional packages:

sudo pip install matplotlib   OR  sudo apt-get install python-matplotlib
sudo pip install -U scikit-learn
sudo pip install pandas

src

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Abhishek Gupta
  • 6,465
  • 10
  • 50
  • 82
  • 2
    Note: it's build-essential :) – Andy Hayden Sep 26 '13 at 18:21
  • 32
    `sudo pip install` is not a pattern that a general purpose answer should include. Usually you want to `pip install` into your virtualenv. – erikbstack Nov 20 '14 at 12:41
  • 1
    This solved my issue, thanks! For Mac users, `libatlas-base-dev` comes with the OS and `gfortran` can be installed using a package ([https://gcc.gnu.org/wiki/GFortranBinariesMacOS](https://gcc.gnu.org/wiki/GFortranBinariesMacOS)) – robodasha Aug 11 '15 at 16:37
  • Echoing erikb85, one should *not* be in the habit of `sudo pip install`ing python libs. Use [virtualenv](https://virtualenv.pypa.io/en/latest/) and [virtualenvwrapper](https://virtualenvwrapper.readthedocs.org/en/latest/). My usual pattern is `sudo apt-get install python-pip` followed by `sudo pip install virtualenvwrapper`. After that *everything* goes into a virtualenv. – DanielSank Oct 13 '15 at 21:13
  • Also make sure you have enough memory (ie. you are running install on some VPS) and create swap file if needed Error message in that case is something like this: `c++: internal compiler error: Killed (program cc1plus) error: Command "c++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -D__STDC_FORMAT_MACROS=1 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c scipy/sparse/sparsetools/csr_wrap.cxx -o build/temp.linux-x86_64-2.7/scipy/sparse/sparsetools/csr_wrap.o" failed with exit status 4` – Tomislav Muic Oct 16 '15 at 12:05
  • This answer works better than the accepted one. In fact the accepted one is dumb way to do it – Trect Jul 02 '19 at 10:25
107

An attempt to easy_install indicates a problem with their listing in the Python Package Index, which pip searches.

easy_install scipy
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Reading http://www.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=27747&package_id=19531
Reading http://new.scipy.org/Wiki/Download

All is not lost, however; pip can install from Subversion (SVN), Git, Mercurial, and Bazaar repositories. SciPy uses SVN:

pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipy

Update (12-2012):

pip install git+https://github.com/scipy/scipy.git

Since NumPy is a dependency, it should be installed as well.

jak119
  • 165
  • 2
  • 11
  • 1
    Brilliant! What did it for me was: `pip install svn+http://svn.scipy.org/svn/scipy/trunk` Note that, following http://stackoverflow.com/questions/651305, you may also choose a given revision (say 5839, which I believe is the last stable version, 0.7.1) using: `pip install http://svn.scipy.org/svn/scipy/!svn/bc/5839/trunk/` although I have not tested that... – Olivier Verdier Feb 06 '10 at 21:02
  • +1 for longevity and robustness. This still works for me 2 years later on OSX 10.8.2 and python 2.7. The standard `pip install scipy` fails during fortan compile (even after successful `brew install gfortran` and `pip install numpy`). The svn install obviates @lokalhort's [github repo install](http://stackoverflow.com/a/7668453/623735) with python3 or @elaichi's dependency `apt-get`s for ubuntu. – hobs Nov 02 '12 at 19:31
  • 2
    Presumably this means you get bleeding edge scipy rather than the latests stable release. – Andy Hayden Sep 26 '13 at 18:24
  • Did not work for me. But this seems to be a good solution. I guess, I am having some other issues and that is why this solution is not working. – Amir Md Amiruzzaman Jul 01 '17 at 01:02
33

In Ubuntu 10.04 (Lucid), I could successfully pip install scipy (within a virtualenv) after installing some of its dependencies, in particular:

$ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-sse2-dev python-all-dev
elaichi
  • 508
  • 5
  • 7
23

To install scipy on windows follow these instructions:-

Step-1 : Press this link http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy to download a scipy .whl file (e.g. scipy-0.17.0-cp34-none-win_amd64.whl).

Step-2: Go to the directory where that download file is there from the command prompt (cd folder-name ).

Step-3: Run this command:

pip install scipy-0.17.0-cp27-none-win_amd64.whl
Lee
  • 29,398
  • 28
  • 117
  • 170
bharat pk
  • 231
  • 2
  • 2
  • 3
    only this option helps me on Windows – coms May 06 '16 at 16:17
  • 3
    This option didn't work for me on Windows7 Cygwin 64bit: scipy-0.17.1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform. – niken May 25 '16 at 19:33
  • @Nik I got the same message. I think it is because your Python instance is 32-bit. Dowloading and installing "scipy-0.18.1-cp27-cp27m-win32.whl" did work for me. – Robin Kramer-ten Have Oct 18 '16 at 06:32
  • this worked for me on Windows, I needed to reinstall `numpy` by using the package from [that site](http://www.lfd.uci.edu/~gohlke/pythonlibs/) and everything worked just fine – josehzz Apr 05 '17 at 22:13
19

I tried all the above and nothing worked for me. This solved all my problems:

pip install -U numpy

pip install -U scipy

Note that the -U option to pip install requests that the package be upgraded. Without it, if the package is already installed pip will inform you of this and exit without doing anything.

Andrew
  • 5,212
  • 1
  • 22
  • 40
Michael Gogel
  • 303
  • 3
  • 7
13

On Fedora, this works:

sudo yum install -y python-pip
sudo yum install -y lapack lapack-devel blas blas-devel 
sudo yum install -y blas-static lapack-static
sudo pip install numpy
sudo pip install scipy

If you get any public key errors while downloading, add --nogpgcheck as parameter to yum, for example: yum --nogpgcheck install blas-devel

On Fedora 23 onwards, use dnf instead of yum.

Shailen
  • 7,909
  • 3
  • 29
  • 37
  • In my virtual env, I changed the last 2 lines of the proposed solution into the following lines: sudo pip install --upgrade pip sudo pip install -U numpy sudo pip install -U scipy – 1man Apr 22 '16 at 17:00
13

If I first install BLAS, LAPACK and GCC Fortran as system packages (I'm using Arch Linux), I can get SciPy installed with:

pip install scipy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user437730
  • 131
  • 1
  • 2
7

For the Arch Linux users:

pip install --user scipy prerequisites the following Arch packages to be installed:

  • gcc-fortran
  • blas
  • lapack
klingt.net
  • 2,019
  • 3
  • 18
  • 19
3

In my case, it wasn't working until I also installed the following package : libatlas-base-dev, gfortran

 sudo apt-get install libatlas-base-dev gfortran

Then run pip install scipy

Pulkit Pahwa
  • 1,412
  • 11
  • 8
3
  1. install python-3.4.4
  2. scipy-0.15.1-win32-superpack-python3.4
  3. apply the following commend doc
py -m pip install --upgrade pip
py -m pip install numpy
py -m pip install matplotlib
py -m pip install scipy
py -m pip install scikit-learn
help-info.de
  • 6,695
  • 16
  • 39
  • 41
3

The answer is yes, there is.

First you can easily install numpy use commands:

pip install numpy

Then you should install mkl, which is required by Scipy, and you can download it here

After download the file_name.whl you install it

C:\Users\****\Desktop\a> pip install mkl_service-1.1.2-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\mkl_service-1.1.2-cp35-cp35m-win32.whl 
Installing collected packages: mkl-service    
Successfully installed mkl-service-1.1.2

Then at the same website you can download scipy-0.18.1-cp35-cp35m-win32.whl

Note:You should download the file_name.whl according to you python version, if you python version is 32bit python3.5 you should download this one, and the "win32" is about your python version, not your operating system version.

Then install file_name.whl like this:

C:\Users\****\Desktop\a>pip install scipy-0.18.1-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\scipy-0.18.1-cp35-cp35m-win32.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1

Then there is only one more thing to do: comment out a specfic line or there will be error messages when you imput command "import scipy".

So comment out this line

from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl

in this file: your_own_path\lib\site-packages\scipy__init__.py

Then you can use SciPy :)

Here tells you more about the last step.

Here is a similar anwser to a similar question.

Community
  • 1
  • 1
Statham
  • 4,000
  • 2
  • 32
  • 45
3

Addon for Ubuntu (Ubuntu 10.04 LTS (Lucid Lynx)):

The repository moved, but a

pip install -e git+http://github.com/scipy/scipy/#egg=scipy

failed for me... With the following steps, it finally worked out (as root in a virtual environment, where python3 is a link to Python 3.2.2): install the Ubuntu dependencies (see elaichi), clone NumPy and SciPy:

git clone git://github.com/scipy/scipy.git scipy

git clone git://github.com/numpy/numpy.git numpy

Build NumPy (within the numpy folder):

python3 setup.py build --fcompiler=gnu95

Install SciPy (within the scipy folder):

python3 setup.py install
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
lokalhorst
  • 31
  • 2
1

Besides all of these answers, If you install python of 32bit on your 64bit machine, you have to download scipy of 32-bit irrespective of your machine. http://www.lfd.uci.edu/~gohlke/pythonlibs/ In the above URL you can download the packages and command is: pip install

Anuroop Pendela
  • 147
  • 1
  • 8
0

For gentoo, it's in the main repository: emerge --ask scipy

automaton
  • 1,091
  • 1
  • 9
  • 23
0

You can also use this in windows with python 3.6 python -m pip install scipy

Ibrahim Isa
  • 529
  • 3
  • 4