Python Install libraries: Difference between revisions
No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
This installation path should work for all versions of Mac OS X, because every library involved and the python interpreter is self-compiled. Make sure to use the system compiler to be compatible to system libraries. | This installation path should work for all versions of Mac OS X, because every library involved and the python interpreter is self-compiled. Make sure to use the system compiler to be compatible to system libraries. | ||
# Install [http://mxcl.github.com/homebrew/ homebrew] using the default settings. | |||
# Install [http://mxcl.github.com/homebrew/ | |||
#: <code>ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"</code> | #: <code>ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"</code> | ||
# Install necessary libraries and python. | # Install necessary libraries and python. | ||
#: <code>brew install gfortran python geos</code> | #: <code>brew install gfortran python geos freetype</code> | ||
#: <code>brew link --force freetype</code> | |||
# Install numpy via the python package manager pip which homebrew installed automatically with python. | # Install numpy via the python package manager pip which homebrew installed automatically with python. | ||
#: <code>pip install numpy</code> | #: <code>pip install numpy</code> | ||
Line 20: | Line 20: | ||
# Install the python-imaging library, which is required for Basemap. | # Install the python-imaging library, which is required for Basemap. | ||
#: <code>pip install PIL</code> | #: <code>pip install PIL</code> | ||
# Basemap itself is unfortunately not available via pip, so you have to compile and install yourself. Download and extract the [http://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/ | # Basemap itself is unfortunately not available via pip, so you have to compile and install yourself. Download and extract the [http://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/ source code from the sourceforge repository]. Then in the extracted directory run | ||
#: <code>python setup.py build</code> | #: <code>python setup.py build</code> | ||
#: <code>python setup.py install</code> | #: <code>python setup.py install</code> | ||
== Testing your installation == | |||
Open an python or ipython shell and type | |||
# to import and test numpy: | |||
#:<code>import numpy as np</code> | |||
#:<code>np.test()</code> | |||
# to import and test scipy: | |||
#:<code>import scipy as sp</code> | |||
#:<code>sp.test()</code> | |||
# to import and test matplotlib | |||
#:<code>import matplotlib as mpl</code> | |||
#:<code>mpl.test()</code> | |||
# to import Basemap | |||
#:<code>from mpl_toolkits.basemap import Basemap</code> | |||
There should be no errors during the imports and during the tests. | |||
== De-Installation == | == De-Installation == | ||
Line 33: | Line 49: | ||
*: <code>which gcc</code> | *: <code>which gcc</code> | ||
*: to make sure to use the system compiler. | *: to make sure to use the system compiler. | ||
* Do not mix pre-compiled and self-compiled libraries. | * Do not mix pre-compiled (installed by a *.dmg- or *.pkg file) and self-compiled libraries. | ||
[[Category:Python | [[Category:Python]] | ||
[[Category:IT]] |
Latest revision as of 17:25, 19 August 2013
Installing numpy, scipy, matplotlib and Basemap on Mac OS X can be challenging.
Installation using homebrew
This installation path should work for all versions of Mac OS X, because every library involved and the python interpreter is self-compiled. Make sure to use the system compiler to be compatible to system libraries.
- Install homebrew using the default settings.
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
- Install necessary libraries and python.
brew install gfortran python geos freetype
brew link --force freetype
- Install numpy via the python package manager pip which homebrew installed automatically with python.
pip install numpy
- Install scipy
pip install scipy
- Install matplotlib
pip install matplotlib
- Install ipython (not necessary, but recommended replacement for the standard python shell)
pip install ipython
- Install the python-imaging library, which is required for Basemap.
pip install PIL
- Basemap itself is unfortunately not available via pip, so you have to compile and install yourself. Download and extract the source code from the sourceforge repository. Then in the extracted directory run
python setup.py build
python setup.py install
Testing your installation
Open an python or ipython shell and type
- to import and test numpy:
import numpy as np
np.test()
- to import and test scipy:
import scipy as sp
sp.test()
- to import and test matplotlib
import matplotlib as mpl
mpl.test()
- to import Basemap
from mpl_toolkits.basemap import Basemap
There should be no errors during the imports and during the tests.
De-Installation
Follow the above commands in the opposite order and replace install
by uninstall
.
Common pitfalls
- Make sure you have no other version of gcc installed. Check the output of
which gcc
- to make sure to use the system compiler.
- Do not mix pre-compiled (installed by a *.dmg- or *.pkg file) and self-compiled libraries.