[PYTHON] Install Scipy on Mac OS Sierra

Overview

I had a hard time trying to install Scipy for scientific calculations, so make a note of the steps to install

environment

Mac OSX Sierra What was installed

result

I have summarized the work that was finally required. The process of specifically fighting the error goes to the next section

First, download and install gFortran for OS X El Capitan from the GCC Wiki Then execute the command

$ pip install Cython
$ git clone https://github.com/scipy/scipy.git
$ cd scipy
$ sudo python setup.py build
$ sudo python setup.py install

The process of actually working

1st error

Honestly try to download

$ git clone https://github.com/scipy/scipy.git
$ cd scipy
$ sudo python setup.py build
Cythonizing sources
(Omission)
Exception: Cython either isn't installed or it failed.
Traceback (most recent call last):
  File "setup.py", line 415, in <module>
    setup_package()
  File "setup.py", line 399, in setup_package
    generate_cython()
  File "setup.py", line 205, in generate_cython
    raise RuntimeError("Running cythonize failed!")
RuntimeError: Running cythonize failed!

I was told that there is no Cython, so I decided to add Cython

$ pip install Cython
(Omitted)
Successfully installed Cython-0.25.2

2nd error

Cython comes in and courageously tries to install Scipy again

$ sudo python setup.py build
(Omitted)
running build_clib
customize UnixCCompiler
customize UnixCCompiler using build_clib
building 'dfftpack' library
error: library dfftpack has Fortran sources but no Fortran compiler found

For a short while, I was angry that I needed a Fortran compiler. Therefore, http://gcc.gnu.org/wiki/GFortranBinaries#MacOS Download and install gFortran for El Capitan from here

Retry Scipy build

I've included gFortran, so I'll retry building Scipy

$ sudo python setup.py build

I was worried about a lot of Warnings being displayed during the build, but the build was completed (it took a long time to build).

Install Scipy

Now that you have a build, install it

$ sudo python setup.py install
(Omitted)
Finished processing dependencies for scipy==0.19.0.dev0+1755a9f

I managed to install it!

Confirmation of Scipy execution

Finally execution confirmation

$ python
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "scipy/__init__.py", line 103, in <module>
    raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
        being in scipy source directory; please exit the scipy source
        tree first, and relaunch your python intepreter.

Rainy day error It seems that he is angry trying to import in the scipy directory, so exit the directory and execute

$ cd..
$ python
>>> import scipy

So that it can be imported safely. Refer to SciPy.org sample and check the execution further just in case.

>>> import numpy as np
>>> from scipy import optimize
>>> np.info(optimize.fmin)
 fmin(func, x0, args=(), xtol=0.0001, ftol=0.0001, maxiter=None, maxfun=None,
      full_output=0, disp=1, retall=0, callback=None, initial_simplex=None)

It worked without any error! Thank you for your hard work.

References

Install SciPy on Mac Install numpy, scipy, gensim I was allowed to reference. Thank you very much.

Recommended Posts

Install Scipy on Mac OS Sierra
Install Sphinx on Mac OS X
Very easy to install SciPy on Mac OS X
Install mitmproxy on Mac OS X
Install pgmagick on Mac OS X 10.9
Install Tensorflow on Mac
Install pyenv on mac
Install Ansible on Mac
Install Python on Mac
Install Python 3 on Mac
Install Python 3.4 on Mac
Install Caffe on Mac
Install mecab on mac
Install mecab-python on Mac
Install pygame on python3.4 on mac
Install tomcat 9 on Cent OS 8
Install module on Anaconda (Mac)
Install OpenPose on mac (Catalina)
Install numba on your Mac
Install pandas 0.14 on python3.4 [on Mac]
Install Django on your Mac
Install pillow on Mac OSX 10.9
[Mac] Tips: Install pyquery on Mac [pyquery]
Memo on Mac OS X
Install PyQt5 with homebrew on Mac OS X Marvericks (10.9.2)
Install Python 3.8 on Ubuntu 18.04 (OS standard)
Install anaconda on Mac → Add Library
How to install mysql-connector-python on mac
Install Adopt OpenJDK 11 on Cent OS 8
Install Python 3.8 on Ubuntu 20.04 (OS standard)
Steps to install matplotlib on Mac
Install python3 on Mac (El Capitan)
How to install OpenCV on Mac
Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)
Install Python 3.9 on Ubuntu 20.04 (OS standard?)
Install Python 2.7 on Ubuntu 20.04 (OS standard?)
Steps to install python3 on mac
How to install Theano on Mac OS X with homebrew
Install Java2Python on macOS High Sierra (10.13)
Install lp_solve on Mac OS X and call it with python.
How to install Theano on Mac OS X 10.10 (using pyenv, anaconda)
Install opencv on Mac using Anaconda Navigator
Install scipy on Linux without internet connection
How to install drobertadams / toggl-cli on Mac
Install matplotlib on OS X El Capitan
Installed aws-cli On Mac OS X Lion
Install 64-bit OS (bate) on Raspberry Pi
scipy stumbles with pip install on python 2.7.8
Install CVXOPT, NumPy, SciPy on Travis CI
Install docker-compose on 64-bit Raspberry Pi OS
Install anaconda on a new Mac anyway
How to install cx_Oracle on macOS Sierra
Run NASA CEA on Mac OS X
Mac OS Preferences
python on mac
[Just a note] Until Keras + TensorFlow works on Mac OS X Sierra
Install NumPy, SciPy, Matplotlib with Homebrew on OS X (as of November 2015)
Install and run Python3.5 + NumPy + SciPy on Windows 10
Preparing to run ImageMagick + im4java on Mac OS
Run Zookeeper x python (kazoo) on Mac OS X
Shpinx (Python documentation builder) on Mac OS X