SciPy Recipes
上QQ阅读APP看书,第一时间看更新

Installing the SciPy stack

Open a Terminal window and enter each of the following commands in succession:

pip3 install --user numpy scipy matplotlib
pip3 install --user ipython jupyter PyQt5
pip3 install --user pandas sympy nose

Make a backup copy of the .bashrc file and open it with a text editor. For example, to use nano, run the following commands in a Terminal window:

cd
cp .bashrc .bashrc.scipy.bak
nano .bashrc

Add the following line at the end of .bashrc:

export PATH="$HOME/.local/bin:$PATH"

Save the file, close the editor, and run the following command from the Terminal window:

source .bashrc

Let's now test the installation. Start Python by running the following command in a Terminal window:

python3

Execute the following lines at the >>> Python prompt. There will be no output and, as long as there are no errors, the installation is correct:

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

Exit Python by running the following at the prompt:

quit()

Back at the Terminal prompt, run the following command:

ipython

This will start IPython, an alternative Python shell with many added features, and print a startup message. You can check that the Python shell is running the expected version of Python from the top line of the startup message. Exit IPython by entering, at the prompt, the following command:

quit()

Back at the Command Prompt, run the following from the command line:

jupyter notebook

If all is correct, the Jupyter Notebook will start on your browser after a while. You have now concluded the installation of Python 3 and the SciPy stack in Linux.