In most use cases the best way to install NumPy on your system is by using an installable binary package for your operating system. Windows ¶ Good solutions for Windows are, Enthought Canopy, Anaconda (which both provide binary installers for Windows, OS X and Linux) and Python (x, y).
Numpy, Scipy and Matplotlib The, and scientific libraries for Python are always a little tricky to install from source because they have all these dependencies they need to build correctly. Luckily for us, has put together some to make it easier to install these Python libraries. First, grab the special formulae (which are not part of Homebrew core): $ brew tap samueljohn/python $ brew tap brewsci/bio Then, install the gfortran dependency which we will need to build the libraries along with gcc: $ brew install gcc Then, install nose, pyparsing and python-dateutil dependency which we will need to build the libraries: $ pip install nose pyparsing python-dateutil pep8 Finally, you can install Numpy and Scipy with: $ brew install numpy scipy matplotlib (It may take a few minutes to build).
This is my preferred way to install Python and Jupyter notebook for doing scientific data analysis. There are many alternative ways of doing this that you can find on Google. I’m doing this on a MacBook Pro (Retina, 13-inch, Early 2015) with macOS High Sierra 10.13.3. In the past, I used virtualenv to manage virtual environments with Python 2. Python3 has built-in handling of virtual environments, so I use that here instead.
If you need to use Python 2, then you’ll want to install virtualenv (see first link at the bottom). Install Homebrew All of these steps are done in the Mac OS Terminal, so start that first.
First install XCode: xcode-select -install Install Homebrew: ruby -e '$(curl -fsSL Open or create the file /.bashprofile and write: export PATH=/usr/local/bin:$PATH Install Python 3 As of 2018-4-9, this will install Python 3 (I think previously it installed Python 2): brew install python Set up virtual environment By default, Python 3 comes with the ability to create virtual environments. Make a folder to host your virtual envs: cd mkdir.virtualenvs Create a virtual env for Jupyter: python3 -m venv.virtualenvs/jupyter/ Run virtual environment and Jupyter Start the virtual env: source.virtualenvs/jupyter/bin/activate Install packages for scientific computing: pip install numpy scipy matplotlib jupyter pandas Run Jupyter: jupyter notebook A browser window will open with the Jupyter file browser in your current working directory. Exit Jupyter and virtual environment Jupyter notebook will run in your terminal window until you close it (with Ctrl-C). You can close the virtual environment with: deactivate UPDATE 2018-04-19: A very useful (and IMO essential) addition to Jupyter notebook is the Table of Contents extension. I show how I install this in a different blog post. References.
The steps above are mostly based on. on Python 3 virtual environments. of how Homebrew installs Python — i.e. Why Python 3 isn’t linked to the command`python`, which motivated some of my deviations from the above blog post.