Posts about macos (old posts, page 1)

2010-10-27 installing python and its components

  • Python is often pre-installed on your system or easy to download. More difficult is to get the essential packages (numpy, scipy, matplotlib, ipython) and their dependencies installed. Here, I list some of the possibilities.

on MacOsX: using MacPorts

  • A basic installation procedure is to use the enthought distribution,

  • Another route is to use MacPorts. It is a generic package manager inspired by what you get using Debian's apt scheme.

  • Once installed, do on the command-line

    • on Leopard:

      sudo port install py25-pil py25-numpy py25-scipy py25-ipython py25-matplotlib +cairo+latex+tkinter
      sudo python_select python25

      (Note: you may also use python26 on Leopard).

    • on Snow Leopard:

      sudo port install py26-numpy py26-scipy py26-ipython py26-matplotlib
      sudo port install py26-pyobjc2-cocoa py26-pil py26-distribute py26-pip py26-py2app python_select
      sudo port install vtk5 +carbon +qt4_mac +python26 py26-mayavi
      sudo python_select python26

      to install a bunch of useful python packages.

    • to get a package that is not available through macports, do:

      sudo easy_install progressbar
  • for visionEgg :

    sudo port install py26-opengl py26-game
    sudo easy_install visionegg

  • on Snow Leopard, you'll have to follow these instructions.

Debian / Ubuntu

DistUtils, PIP & Easy Install

  • most of the time, there's a file:

    python install --prefix=~
  • See

  • to install numpy (same for pylab, scipy, or visionegg), simply do

    easy_install numpy
  • most of the cases, on a test server or a single-user machine, you may find more useful to install in your home dirtectory, for instance:

    easy_install -d ~/lib/python2.5/site-packages/ numpy
  • to upgrade, use

    easy_install -U numpy
  • you can browse the list of available packages.

  • for pip:

  • you may create a script tu update all packages:

    for i in `python -c "for dist in __import__('pkg_resources').working_set: print dist.project_name"`:
    echo "`easy_install -U $i`"
    echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
  • to install PIL, use

    easy_install -d lib/python2.6/site-packages/ --find-links Imaging

SVNs: bleeding edge versions

  • numpy

    svn co numpy
    cd numpy
    python build
    sudo python install
    rm -rf build
    cd ..
  • SciPy

    svn co scipy
    cd scipy
    python build
    sudo python install
    rm -rf build
    cd ..
  • pylab

    svn co matplotlib
    cd matplotlib
    python build
    sudo python install
    sudo rm -rf build
    cd ..
  • SPE

    svn checkout svn://
  • PIL

    tar zxvf  Imaging-1.1.6.tar.gz
    cd Imaging-1.1.6
    python build_ext -i
    python install
  • gsl

    cvs -d login
    cvs -d checkout gsl
    cd gsl/
    ./configure --enable-maintainer-mode
  • pytables

    • dependency on HDF

      tar zxvf hdf5-1.6.5.tar.gz
      cd hdf5-1.6.5
      ./configure --enable-cxx
      make install
      h5ls -r  Documents/Sci/projets/virtualV1/experiments/benchmark_one/results/benchmark_retina_high.h5
      tar zxvf Pyrex-
      cd Pyrex-
      python build
      sudo python install
      rm -rf build
    • install

      #svn co pytables
      tar zxvf pytables-1.4.tar.gz
      cd pytables-1.4
      export DYLD_LIBRARY_PATH=/sw/lib # or in .bashrc
      python install --hdf5=/sw
      cd ..
  • pygtk

    tar xvfj pygtk-2.8.6.tar.bz2
    cd pygtk-2.8.6
    sudo make install    # or without sudo as root
    cd ..


2010-09-27 bundling using py2app

2010-09-28 05:44:57

using macports

  • install py2app :

    sudo port install -u  py26-py2app
  • there's sometimes a problem in py2app to check the right architecture to build on:

    find /opt/local -name apptemplate/
    sudo vim /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py2app/apptemplate/
  • in this case, this can be done by adding the following lines to py2app/apptemplate/

    gPreBuildVariants = [
            'name': 'main-x86_64',
            'target': '10.6',
            'cflags': '-isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64',
            'cc': 'gcc-4.2',
            'name': 'main-i386',
            'target': '10.6',
            'cflags': '-isysroot / -arch i386',
            'cc': 'gcc-4.2',

    . So, change to

    gPreBuildVariants = [
            'name': 'main-x86_64',
            'target': '10.5',
            'cflags': '-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch x86_64',
            'cc': 'gcc-4.2',
    #     {
    #         'name': 'main-universal',
    #         'target': '10.5',
    #         'cflags': '-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc -arch ppc64 -arch x86_64',
    #         'cc': 'gcc-4.2',
    #     },
    #     {
    #         'name': 'main-fat3',
    #         'target': '10.5',
    #         'cflags': '-isysroot / -arch i386 -arch ppc -arch x86_64',
    #         'cc': 'gcc-4.2',
    #     },
    #     {
    #         'name': 'main-intel',
    #         'target': '10.5',
    #         'cflags': '-isysroot / -arch i386 -arch x86_64',
    #         'cc': 'gcc-4.2',
    #     },
    #     {
    #         'name': 'main-fat',
    #         'target': '10.3',
    #         'cflags': '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc',
    #         'cc': 'gcc-4.0',
    #     },

using homebrew


2010-08-31 managing packages on MacOsX : testing HomeBrew

2010-08-31 09:11:31
  • a newcomer after fink and MacPorts:

  • advertised here

  • install

     $ ruby -e "$(curl -fsS"
    ==> This script will install:
    Press enter to continue
    ==> Downloading and Installing Homebrew...
    ==> Installation successful!
  • fix permissions

    $ sudo chown -R `whoami` /usr/local
  • to install python specific stuff, use pip:

    brew install pip
    echo '[install]
    install-data=/usr/local/Cellar/PyPi/2.6/share' > ~/.pydistutils.cfg
    pip install ipython
  • this is with the exception of numpy + scipy, the latter needing

    cd tmp
    svn co numpy
    pip install numpy
    brew install suite-sparse
    svn co scipy
    pip install scipy


2010-08-30 shortcuts

2010-08-31 09:35:58
  • from

    To make Ctrl← and Ctrl→  useful again, that is going a word forward or backward like they usually do on Linux, you must make send the right string to the shell. In the preferences, go to the Settings tab and select your default profile. Go to Keyboard and set control cursor left and control cursor right to send string \033b and \033f respectively.
    While your're at it, you can also fix Home (\033[H), End (\033[F), Page Up (\033[5~) and Page Down (\033[6~) so that they send those keys to the shell instead of scrolling the buffer.


2010-08-29 System Updates

  • install a package

    sudo installer -pkg <chemin d’accès au paquet> -target /
  • CLI for Software Updates :

    sudo softwareupdate -i -a


2010-08-03 compiling OpenCV on MacOSX 10.6

2010-08-03 12:14:29

using macports

  • it works now with macports:

    sudo port install -u opencv +python26 +tbb

latest SVN

  • compiling here along with MacTex...

  • from

    svn co
    cd opencv # the directory containing INSTALL, CMakeLists.txt etc.
    mkdir build
    cd build
    cmake -D CMAKE_OSX_ARCHITECTURES=x86_64 -D WITH_FFMPEG=ON -D BUILD_EXAMPLES=ON -D BUILD_LATEX_DOCS=ON -D PDFLATEX_COMPILER=/usr/texbin/pdflatex -D BUILD_NEW_PYTHON_SUPPORT=ON  -D PYTHON_LIBRARY=/opt/local/lib/libpython2.6.dylib -D PYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Headers ..
    make -j4
    sudo make install
  • I had to rebuild some ports

    sudo port install ilmbase
    port provides /opt/local/lib/libIlmImf.dylib
    sudo port install openexr
    sudo port install libdc1394

    and recompile

  • then could run

    cd ../samples/python/

using homebrew

  • another route is homebrew: / :

    $ brew info opencv
    opencv 2.1.1-pre
    Depends on: cmake, pkg-config, libtiff, jasper, tbb
    /usr/local/Cellar/opencv/2.1.1-pre (96 files, 37M)
    The OpenCV Python module will not work until you edit your PYTHONPATH like so:
      export PYTHONPATH="/usr/local/lib/python2.6/site-packages/:$PYTHONPATH"
    To make this permanent, put it in your shell's profile (e.g. ~/.profile).


2010-03-15 securing the server

This page is word-editable, please edit if you find an error.

  • SSH (Secure Shell) is installed on most systems (here GnuLinuxUbuntu and MacOsX) so don't panic about compilations (try Putty on Windows). Try a simple ssh-V to check version or whichssh to locate the binary.
  • Thanks to ssh, you can transport all your data (accessing files, merging repositories, lauching remote X programs) transparently using a secure connection. Thanks to tunneling, this is also simpler thus more secure for your computer and your provider. Having all security located in one interface sure is a big advantage: once your SSH communication channel is set-up, you should only focus on what you wish to do (SVN, etc...).
  • Most documentation may be found in manssh, manssh-keygen (remember that thanks to the underlying pager system, you can search for a keyword, for instance hello, by typing \hello[ENTER]). Many other sources of help exist, such as this FAQ

Setting up SSH: spreading the good keys

  1. There are many ways to authenticate your session, but mainly password or keys. Keys are to be preferred to avoid typing your password 10 times a day. It is also most secure (you type your key's password locally and not remotely).

  2. Generate a private/public key pair. Simple command to do this:

    ssh-keygen -t rsa
  3. Copy the key to the

    ssh-copy-id -i ~/.ssh/ username@host

    . this can be also be done using

    scp ~/.ssh/ username@host:~/
    ssh username@host
    cat >> .ssh/authorized_keys
  4. Now try logging into the remote machine again from local

    ssh REMOTE_USERNAME@remote_host
  5. Check that your public key is in the list of authorized keys: .ssh/authorized_keys.

  6. Change password regularly:

    ssh-keygen -p

    It is not advised to put an empty pass-phrase, rather use key agent (see below).


  • it is possible to create alias of the ssh binary to hostnames... but more simply, you may put

    alias myserver='ssh -Y -p2221'

    where 2221 is here the port used by the SSH server on

  • more cleanly, you may edit your `` .ssh/config`` file with:

            User myuser
            Port 2221

    Be careful that properties are right : chmod600~/.ssh/config

key agent

  • An agent loads your keys on the local machines:
    • it's more secure, since all passwords are typed locally, you only send encrypted authentifications
    • it's more practical, since you type your password once per session
  • GUI interface on MacOsX :
    • install with macports using sudoportinstallSSHKeychain, you'll find it in /Applications/MacPorts

securing the server

  • Robots usually try common name / password combinations on your SSH server. If you're the only user admin_name of your server you may use in the SSH server configuration file (usually /etc/ssh/sshd_config) the option AllowUsersadmin_name to restrict access to user admin_name and avoid brute force attacks. Since robots are most of the time dumb, they'll get an immediate accesdenied response to any connection request.
  • Robots usually sniff port 22. To change the port which is listened by the SSH server, either modify the default port in the SSH server configuration file (usually /etc/ssh/sshd_config). Another way is to use your router to redirect the outside port (for instance 2221) to the default port of your server.


2009-11-26 inkscape native

2009-11-26 09:27:37
  • trying out

  • build dependencies

    sudo port install autoconf automake
    sudo port install librsvg libwpd libwpg libcroco
    sudo port install libxslt boost boehmgc gtkmm lcms intltool popt
    sudo port install cairo +quartz+no_x11 cairomm pango +quartz+no_x11 poppler +quartz gtk2 +quartz
    sudo port install gsl
    sudo port install hicolor-icon-theme
    sudo port install subversion
    sudo port install libxml2 libxslt
    # optional to speed up the compiling process:
    sudo port install ccache
    export CC="ccache gcc"
    export CXX="ccache g++"
  • getting the sources

    cd tmp
    svn co inkscape
    cd inkscape/packaging/macosx/
  • compile

    # Edit the file to remove the configure option --enable-osxapp
    # (line 24)
    # I used TextWrangler for this, pico or another command line editor will do the same.
    # Back to the terminal:
    # configure it:
    sudo ./ c
    # build it:
    sudo ./ b
    # install it:
    sudo ./ i
    # test it:

    compiles ok :-), but crashes rather rapidly :-(


2009-08-29 Tips on Filesystems, security and al on mac os x

  • mount with AFP sharepoints from the command line (thanks to this hint) :

    # mount_afp [-i] [-o options] afp_url node
    mkdir /Volumes/truc
    mount_afp afp://user:PASSWORD@server/truc /Volumes/truc
    umount /Volumes/truc
    rmdir /Volumes/truc

finder nags when changing a file's extension

  • read the default value (should be 0)

    defaults read FXEnableExtensionChangeWarning
  • change it:

    defaults write FXEnableExtensionChangeWarning False

Make spell check show only desired languages


  • Mac OS X Filesystems

  • One feature of HFS volumes is that fle are referred to as links: for instance you can read a PDF file while changing the name at the same time. No problem!

  • Safely remove '._' files created by HFS(+)

    find . -name '._*' -print0 | xargs -0 rm


  • to remove the remaining index files on the volume using the command: `` sudo mdutil -E /Volumes/volume_name `` utilitaires CLI :

    sudo mdutil --help
    mdutil: unrecognized option `--help'
    usage: mdutil -pE volume ...
            mdutil can be used to manage the metadata stores used by Spotlight.
            -p              publish metadata for the provided volumes.
            -i (on|off)     set indexing status for the provided volumes.
            -E              erase the master copy of the metadata stores for the provided volumes.
            -s              print indexing status for the provided volumes.

System & Security


  • to scan for open ports on a remote machine :

    sudo nmap -T3 -vv -sS -p 1-65535 -P0
    Starting nmap 3.81 ( ) at 2006-04-05 16:32 CEST
    Initiating SYN Stealth Scan against [65535 ports] at 16:32
    Discovered open port 80/tcp on
    SYN Stealth Scan Timing: About 2.18% done; ETC: 16:55 (0:22:26 remaining)

Dash board

  • Don't use Dashboard? No particular reason to leave it running, consuming memory. Following, you can turn Dashboard off by doing:

    defaults write mcx-disabled -boolean YES
    killall Dock
  • Unsurprisingly, you change YES to NO to re-enable Dashboard:

    defaults write mcx-disabled -boolean NO
    killall Dock

Unix - X11

Change login window on (Snow) Leopard

  • disrupted by the look of the plasma flames? think it looks like a cheap star trek sundae? check :

    cd /System/Library/CoreServices
    sudo rm DefaultDesktop.jpg
    #sudo mv DefaultDesktop.jpg DefaultDesktop_old.jpg # if you want to keep the Aurora stuff (it stills around, do a 'locate Aurora'
    sudo ln -s /Library/Desktop\ Pictures/Nature/Stones.jpg DefaultDesktop.jpg


2008-08-29 keyboard

Touches spéciales (unix) sur clavier Mac francais

Merci a !

backslash \ shift + option + /
pipe, or | shift + option + L
tidle ~ option + N
simple quote ' 4 key, that's to say a regular ' on any keyboard I guess.
opening brace { option + (
closing brace } option + )
opening square bracket [ shift + option + (
closing square bracket ] shift + option + )

Apple also got the habit to give it's own special names to some keys:

  • ctrl is called, well, control. So far, so good.
  • the alt key (with a funy sign under it) is called option.
  • the key with a funny sharp and the Apple logo is called command (for we are supposed to be so creative Apple users I think), or sometimes more logically apple.

keyboard shortcuts

  • in Finder (and most other applications)
    • ⌃⌘Z to zoom the window
    • ⌘ + ` to switch between your windows
    • ⇧⌘[ and ⇧⌘] to switch tabs
    • ⌃⌘D to show the dictionary
  • in Firefox:
    • Fn + Alt + Left arrow gets you to the home page.
    • Command + L : link bar
    • Command + K: search box
    • Ctrl + Tab: Next Tab
  • see Mac OS X keyboard shortcuts