================================
Scientific Python Installation
================================
test
Introduction
================
As engineers, we need to install not only Python, but the necessary
modules and tools for doing scientific stuff, matrices, arrays,
plotting, and so on. This is sometimes call the scipy stack among
scientific python people. Instructions for different operating
systems are below:
- `Windows`_
- `MacOSX`_
- `Ubuntu`_
.. _Windows:
Windows
=======
The easiest way to get everything you need for scientific python on
windows is to install Anaconda. Note that once you install Anaconda,
you do not need to install anything else. Go to
``_ and choose "Download
Anaconda".
I made several install videos for downloading, installing, and
configuring anaconda and ipython in windows:
- `Video 1: downloading anaconda `_
- `Video 2: install anaconda `_
- `Video 3: ipython configuration `_
- `Video 4: spyder configuration `_
.. _SpyderVideos:
Spyder Tips/Verification
------------------------
- YouTube video of basic `Spyder verification `_
- YouTube video of `Spyder Tips `_
Windows Verification
------------------------
- In Windows, you basically need to install Anaconda and configure
Spyder and you should be good to go
- You have a working scientific Python installation when you can plot
a sine wave
- Launch Spyder from the windows start button search and type this
code into the IPython console in the bottom right this code:
.. _ipythoncode:
.. code-block:: python
t = arange(0,1,0.01)
y = sin(2*pi*t)
figure(1)
clf()
plot(t,y)
show()
If that code executes without an error and you see a sine wave in a
plot window, you are good to go.
Executing or Running a file in IPython (Windows)
------------------------------------------------
Here is a short video on running a Python file in IPython or how to
use a text editor like Notepad++ with IPython:
- `IPython Console run command `_
.. _MacOSX:
Mac OSX
==========
Mac users have two options. The first is to install Anaconda.
Anaconda is easy, but it also takes up a lot of hard drive space. If
you have any interest in learning to use the terminal and unleashing
its power, I strongly encourage you to use homebrew and pip.
Anaconda
------------
If you choose to go the Anaconda route, go to
``_ and choose "Download
Anaconda".
Homebrew and PIP
----------------
For Mac users, I strongly recommend using homebrew and pip to install
the things we need. This blog is a pretty good explanation, but note
that his ruby command for installing homebrew itself is outdated:
``_
Basically, you need to first install Xcode. You used to have to
register as a developer with Apple to do this. It was free, but you
had to register. You might now be able to install it directly from
the app store.
Once you have Xcode installed, install `homebrew `_.
Homebrew is a tool for installing Unix and Linux open-source software
from the command line. You install homebrew with this command from
the terminal:
:code:`ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
You then have to add this line to your :code:`~/.profile` file
(:code:`~` means your home directory):
:code:`export PATH=/usr/local/bin:/usr/local/share/python:$PATH`
Use homebrew to install python by typing this at the terminal:
:code:`brew install python`
Important Check
--------------------
If you homebrew installed correctly and homebrew installed its own
python, you should be able to type :code:`which python` at the
terminal and the response **must** be:
:code:`/usr/local/bin/python`
PIP
-----
Pip is a python installation tool. To get it type
:code:`easy_install pip`
**Note:** installing :code:`gcc` and :code:`scipy` can take up to an
hour depending on your internet connection and processor speed. Don't
start these processes if you can't let your computer run for a bit.
You should be able to do other things while it is working in the
background, but don't stop these processes or shutdown your computer
until they finish.
You will also need a fortran compiler to install scipy. It is in the
:code:`gcc` package. Type:
:code:`brew install gcc`
Once you have pip and gcc, you can install the following:
:code:`pip install numpy`
:code:`pip install scipy`
We need one last random thing from homebrew:
:code:`brew install pkg-config`
and then we can wrap up with
:code:`pip install matplotlib`
:code:`pip install ipython`
:code:`pip install pyserial`
Mac OSX Spyder Installation
---------------------------
Once you have python and the scientific packages installed, I
recommend installing the Spyder IDE if you prefer an integrated
development environment:
Mac OSX Verification
------------------------
You have correctly installed scipy and friends in OSX when you can
generate a sine wave as described above in the code block
`ipythoncode`_ under Windows Verifciation. You can do this either in
Spyder or using IPython from the terminal.
See the links above for `SpyderVideos`_ on verificaiton and tips.
To launch IPython from the terminal, open a terminal and type
:code:`ipython --pylab --profile=scipy`
this can be saved as an alias in a file called :code:`.profile` in
your home directory:
:code:`alias scipy='ipython --pylab --profile=scipy'`
.. _Ubuntu:
Ubuntu
======
Ubuntu users should be able to do something like
:code:`sudo apt-get install python-numpy python-scipy python-matplotlib ipython`
and then launch IPython as described for OSX. The alias would need to
go in a file called :code:`.bash_profile`. Plotting a sine wave would
prove basic functionality as described above in `ipythoncode`_.