Actions

Difference between revisions of "OSX"

From ACL@NCU

 
(2 intermediate revisions by the same user not shown)
Line 61: Line 61:


This is because when you import mvpa2 under the pymvpa source code directory (where you make it), python takes the mvpa-subdirectory as the place from where is imports the mvpa-package. This won't work, at least for SVM / SMLR, that use C-code bindings that have to be compiled ([https://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/2011q1/001571.html source]).
This is because when you import mvpa2 under the pymvpa source code directory (where you make it), python takes the mvpa-subdirectory as the place from where is imports the mvpa-package. This won't work, at least for SVM / SMLR, that use C-code bindings that have to be compiled ([https://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/2011q1/001571.html source]).
=[http://blog.manbolo.com/2014/09/27/use-python-effectively-on-os-x Use python effectively in OSX]=
After Homebrew installation is done, we can install Python. We’re going to start by installing Python 2.7:
<pre>
$brew install python
</pre>
Now, we need to tell the system to use our freshly new Python interpreter instead of the default one.
<pre>
$ which python
/usr/bin/python
</pre>
The default Python interpreter is under /usr/bin, and the Homebrew’s one is under /usr/local/bin so we’re going to edit /etc/paths so the /usr/local/bin binaries will be prioritised over /usr/bin.
<pre>
$ sudo nano /etc/paths
</pre>
If you open /etc/paths, you should see this:
<pre>
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin 
</pre>
Move /usr/local/bin at the beginning of the file so Homebrew binaries take on system binaries;
<pre>
/usr/local/bin 
/usr/bin
/bin
/usr/sbin
/sbin
</pre>
Finally, check everything is ok: typing python should launch the Homebrew version
<pre>
$ source /etc/paths
$ which python
/usr/local/bin/python
$ python
Python 2.7.8 (default, Jul  2 2014, 10:14:46)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
</pre>

Latest revision as of 07:33, 3 June 2016

System

Install Homebrew on OS earlier than 10.9

ruby -e "$(curl -fsSkL raw.github.com/mistydemeo/tigerbrew/go/install)"

(in .bash_profile)
export PATH=/usr/local/sbin:/usr/local/bin:$PATH


Install pymvpa (adapted from Moffet's Crash Log)

1) Install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install"
2) mkdir /Users/Shared/PyMVPA; cd  /Users/Shared/
3) sudo easy_install pip
4) pip install virtualenv
5) virtualenv PyMVPA
6) cd PyMVPA
7) . bin/activate
8) pip install numpy
9) pip install scipy
10) pip install nibabel
11) pip install ipython'[all]'
12) pip install scikit-learn
13) pip install matplotlib
14) brew install swig
15) Grab the PyMVPA source (and place into your virtualenv folder):

git clone git://github.com/PyMVPA/PyMVPA.git

16)Install libsvm:
brew install gnuplot
brew install qt4
brew install libsvm


17)Install PyMVPA:
make 3rd
python setup.py build_ext –with-libsvm
python setup.py install –with-libsvm
18) Download tutorial data at: http://data.pymvpa.org/datasets/haxby2001/
19) Unzip and Place data in /Users/Shared/PyMVPA/Tutorial_Data


And remember that you should cd to another directory when calling the test command:


from  mvpa2.tutorial_suite import *

Otherwise you will see the following complaint:

WARNING: Failed to load fast implementation of SMLR.  May be you forgotten to build it.  We will use much slower pure-Python version. Original exception was dlopen(mvpa2/clfs/libsmlrc/smlrc.so, 6): image not found
 * Please note: warnings are printed only once, but underlying problem might occur many times *
WARNING: SMLR: C implementation is not available. Using pure Python one

This is because when you import mvpa2 under the pymvpa source code directory (where you make it), python takes the mvpa-subdirectory as the place from where is imports the mvpa-package. This won't work, at least for SVM / SMLR, that use C-code bindings that have to be compiled (source).


Use python effectively in OSX

After Homebrew installation is done, we can install Python. We’re going to start by installing Python 2.7:

$brew install python

Now, we need to tell the system to use our freshly new Python interpreter instead of the default one.

$ which python
/usr/bin/python

The default Python interpreter is under /usr/bin, and the Homebrew’s one is under /usr/local/bin so we’re going to edit /etc/paths so the /usr/local/bin binaries will be prioritised over /usr/bin.

$ sudo nano /etc/paths

If you open /etc/paths, you should see this:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin  

Move /usr/local/bin at the beginning of the file so Homebrew binaries take on system binaries;

/usr/local/bin  
/usr/bin
/bin
/usr/sbin
/sbin

Finally, check everything is ok: typing python should launch the Homebrew version

$ source /etc/paths
$ which python
/usr/local/bin/python

$ python
Python 2.7.8 (default, Jul  2 2014, 10:14:46)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.