Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SciPy Recipes

You're reading from   SciPy Recipes A cookbook with over 110 proven recipes for performing mathematical and scientific computations

Arrow left icon
Product type Paperback
Published in Dec 2017
Publisher Packt
ISBN-13 9781788291460
Length 386 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
V Kishore Ayyadevara V Kishore Ayyadevara
Author Profile Icon V Kishore Ayyadevara
V Kishore Ayyadevara
Ruben Oliva Ramos Ruben Oliva Ramos
Author Profile Icon Ruben Oliva Ramos
Ruben Oliva Ramos
Luiz Felipe Martins Luiz Felipe Martins
Author Profile Icon Luiz Felipe Martins
Luiz Felipe Martins
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting to Know the Tools FREE CHAPTER 2. Getting Started with NumPy 3. Using Matplotlib to Create Graphs 4. Data Wrangling with pandas 5. Matrices and Linear Algebra 6. Solving Equations and Optimization 7. Constants and Special Functions 8. Calculus, Interpolation, and Differential Equations 9. Statistics and Probability 10. Advanced Computations with SciPy

Installing SciPy from a binary distribution on Windows

Windows does not ship with any version of Python pre-installed, which actually makes things easier when we want to install our own version of Python.

On the other hand, the installation of a full SciPy stack in Windows is somewhat more complex, due to conflicts that exist between the Python distribution and certain Windows libraries. We indicate an installation route that has been tested several times, but some trial and error may be necessary due to changes in the distribution.

How to do it...

To make the instructions easier to follow, the installation procedure is broken down into two stages:

  • Installing Python
  • Install the SciPy stack

Installing Python

  1. Go to https://www.python.org and download the Python 3 binary distribution for Windows
  2. Once the download finishes, double-click on the installation file to start the setup
  3. Check the box Add Python 3.x to PATH
  4. Click the Install Now option
  5. Select the Disable the path length limit option, if available, on the last installation screen
  6. Close the installation screen

These steps will install Python in the folder:

C:\Users\username\Appdata\Local\Programs\Python\Python3x

To test the installation, start a Command Prompt window and enter the following command:

python3

If all is correct, the Python command-line interpreter will start and display information about the version of Python being run. For now, just exit the interpreter by entering, at the >>> Python prompt, the following statement:

quit()

Now, let's check if pip was correctly installed. Enter the following at the command line:

pip --version

This should print information about the currently installed version of pip3, including the location where packages will be installed. As long as no errors are reported, the installation is correct.

Installing the SciPy stack

To install SciPy, we need to first download the versions of the library that have been built specifically for Windows. They can be found at the following site: http://www.lfd.uci.edu/~gohlke/pythonlibs/.

This page contains a long list of pre-compiled Python packages for Windows. Search the page for numpy-mkl and scipy and look for a package that matches your operating system and Python distribution. In my case, I found the following two files:

numpy-1.12/1+mkl-cp36-cp36m-win_amd64.whl
scipy-0.19.0-cp36-cpm36m-win_amd64.whl

Notice that the package names refer to version 3.6 and a 64-bit architecture. Make sure the versions you download match your Python 3 distributions. Open a command window on the directory where the files were saved and enter the following two commands, in the following order:

pip install numpy-1.12/1+mkl-cp36-cp36m-win_amd64.whl
pip install scipy-0.19.0-cp36-cpm36m-win_amd64.whl

After installing NumPy and SciPy, pip can be used to install the other packages directly by running the commands shown as follows:

pip install matplotlib
pip install ipython jupyter
pip install pandas sympy nose

Let's now test the installation. First, start Python 3 and execute the following statements at the >>> Python prompt:

import numpy
import scipy
import matplotlib
import pandas
import IPython
import sympy

If you can run all these commands and there are no errors, the installation of the packages is correct. Exit the Python shell by running the following statement:

quit()

Now, back in the command window, run the following command:

ipython

This will start IPython and display information about the installed version. For now, simply exit IPython by running the following at the prompt:

quit()

Finally, let's test the Jupyter Notebook. At the command line, run the following command:

jupyter notebook

If all is correct, this will start the Jupyter Notebook in your browser after a few seconds. This finishes the installation of Python and the SciPy stack in Windows.

You have been reading a chapter from
SciPy Recipes
Published in: Dec 2017
Publisher: Packt
ISBN-13: 9781788291460
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime