Install NumPy, SciPy, Matplotlib with Python 3 on Windows
Posted on February 25, 2017 by Sol
We’ll start by installing the latest stable version of Python 3, which at the time of this writing is 3.6. Head over to https://www.python.org/downloads/ and download the installer. The default Python Windows installer is 32 bits and this is what I will use in this article. If you need the 64 bits version of Python, check the Looking for a specific release? section from the above page.
Start the installer and select Customize installation. On the next screen leave all the optional features checked. Finally, on the Advanced Options screen make sure to check Install for all users, Add Python to environment variables and Precompile standard library. Optionally, you can customize the install location. I’ve used C:\Python36. You should see something like this:
Press the Install button and in a few minutes, depending on the speed of your computer, you should be ready. Now, to check if Python was correctly installed, press and hold the SHIFT key and right click with your mouse somewhere on your desktop, select Open command window here. Alternatively, on Windows 10, use the bottom left search box to search for cmd.
Now, write python in the command window and press Enter, you should see something like this:
Next, download and install the Microsoft Visual C++ 2015 Redistributable. Be sure to select the version corresponding to your Python installer (32 or 64 bits).
Download the NumPy version corresponding to your Python installation from here. In my case, I’ve used numpy-1.12.0+mkl-cp36-cp36m-win32.whl
Download the SciPy version corresponding to your Python installation from here. In my case, I’ve used scipy-0.18.1-cp36-cp36m-win32.whl
Download the Matplotlib version corresponding to your Python installation from here. In my case, I’ve used matplotlib-2.0.0-cp36-cp36m-win32.whl
Now, open a cmd window like before. You can open this directly in your Downloads folder if you SHIFT and right click inside it. The idea is to open a cmd window where you’ve downloaded the above two files. Use the next set of commands to install NumPy, SciPy and Matplotlib:
1 pip install numpy-1.12.0+mkl-cp36-cp36m-win32.whl 2 pip install scipy-0.18.1-cp36-cp36m-win32.whl 3 pip install matplotlib-2.0.0-cp36-cp36m-win32.whl
After each of the above commands you should see Successfully installed ….
Launch Python from a cmd window and check the version of Scipy, you should see something like this:
1 C:\Users\x\Downloads>python 2 Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32 3 Type "help", "copyright", "credits" or "license" for more information. 4 >>> import scipy as sp 5 >>> sp.version.version 6 '0.18.1' 7 >>>
Let’s try something a bit more interesting now, let’s plot a simple function with Matplotlib. First, we’ll import SciPy and Matplotlib with:
1 import scipy as sp 2 import matplotlib.pylab as plt
Next, we can define some points on the (0, 1) interval with:
1 t = sp.linspace(0, 1, 100)
Now, let’s plot a parabola defined by the above interval:
1 plt.plot(t, t**2) 2 plt.show()
You should see something like this:
If you want to learn more about Python and Matplotlib, I recommend reading Python Crash Course by Eric Matthes. The book is intended for beginners, but has a nice Data Visualization intro to Matplotlib chapter:
Another good Python book, for more advances users, which also uses Matplotlib for some of the book projects is Python Playground by Mahesh Venkitachalam:comments powered by Disqus