Sunpy in a Mac... a different approach: Step by step...

75 views
Skip to first unread message

DVD PS

unread,
Mar 1, 2012, 7:20:50 AM3/1/12
to sunpy, Peter Gallagher
Hello everyone, I'm back, and I now know how to install Sunpy in the Macs

I've finally managed to install sunpy, and all its dependencies in the Mac.  I've found that it was not trivial, and that people were complaining about it.  So I when and ask to the python gurus in the python Ireland group.  Many are mac users, so they should now.  Right, I was pointed to the best one: a guy that's used to work with scientists.  He told me everything I needed.

1) Easiest option, distribute a virtual machine with a easy linux distribution with all what we need installed there.  This is good but not ideal.

 2) Use homebrew + pip and create a tar file which it can be used to everyone that has same OS X version and Xcode.  This is a good one.  So, what's homebrew? homebrew is a tool like ports or fink, but compiling everything. It works very nicely, and you can configure it to save all the binaries to certain directory, and then tar it and pass it to someone else.  I see the future in here!!!  Though if we want to put things easy we would need to run the whole thing for all the different Xcode versions and OS X available... but probably we could just do it to the most common: snow, snow leopard and lion (and their default Xcodes).

Also, the last and important step, is the virtualenv.  A python tool where you can save and compile everything you need for that environment.  So you don't need to use sudos to install anything, and as before (I think), you could import that virtualenv together with the homebrew directories and have all python dependencies.

So, what I did? There we go (note, to make it simpler I used python 2.7.2.  Python3 is left as an exercise to whoever has more time):

Machine I've got: a virgin 10.6.8 Mac that comes with Python 2.6.1  and Xcod 3.2.6 (installed from disk when Mac installed)
Note: All lines that start by $ means that you run that on the terminal. 

Python2.7.2:  It's suggested everywhere that I used the official python, so, I donwloaded from here: http://www.python.org/download/ 2.7.2
                      Package installed through double click   => EASY!

Homebrew:    This is a tool to install unix tools (similar to fink or ports, but more closed to emerge in gentoo)
                       Up-to-date instructions of installation in: https://github.com/mxcl/homebrew/wiki/installation
                       Installation:
                                NO_PROXY => If you don't have proxys then you just need to do:
                                        $ /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
                                and follow instructions.
                                PROXY  =>  change proxy_user, proxy_pass and proxy.domain.com:888 by your local setups:
                                      $ /usr/bin/ruby -e "$(curl -U proxy_user:proxy_pass -x proxy.dommain.com:888 -fsSL https://raw.github.com/gist/323731|sed  -e  's/curl/curl -U proxy_user:proxy_pass -x proxy.dommain.com:888 /')"
                       Installed => EASY!!

Other packages:  All right, this is what I did at the beginning, before using the virtualenv stuff... thinking that it was going to be easier that way...  So, in my system I installed the following stuff:

First, for those with PROXY you need to set your variables for use easy_install, brew and other tools that downloads stuff from the outside world.
           What do you use? bash or cshell? if you don't know I think that this may help:
                 $ set | grep -i csh
           You don't get anything? then probably you are using bash, if you get something like "shell   /bin/tcsh" then you are using tcsh ;-)
           bash: $ export http_proxy=http://proxy_user:proxy...@proxy.dommain.com:888
           csh: $ set http_proxy 'http://proxy_user:proxy...@proxy.dommain.com:888'   # I think it's right... but I have not checked this.

  gfortran
                 $ brew install gfortran
  setuptools
                 $ easy_install -a setuptools

Probably, you don't need to install the following three packages (readline, ipython and numpy) in here, as I do them again afterwards, so I think it's safe to skip them:
  Readline
                 $ easy_install -a readline
  ipython
                 $ easy_install -a ipython
  numpy
                 $ easy_install -a numpy     #shows a lot of errors, but it seems to work... anyway, I installed later again in the virtualenv...


So,  now it's when I change stratey: 
Virtual_env
                $ curl -U proxy_user:proxy_pass -x proxy.dommain.com:888 -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
                $ python virtualenv.py solar_env
                $ . solar_env/bin/activate  # Notice the dot before solar_env
  Now you are inside the virtualenv (solar_env) and you should see that the prompt of your shell has changed, so now, (solar_env)$ it's what I do inside that environment.
  I'm installing again all the dependencies.  PIP comes in the virtual_env, so there's not need to install pip (that makes things easier)
                (solar_env)$  easy_install -a readline
                (solar_env)$  pip install ipython
                (solar_env)$  pip install numpy
                (solar_env)$  pip install scipy
For matplotlib I got some info from here: http://telliott99.blogspot.com/2011/07/matplotlib-on-os-x-lion-revised.html  but you don't need to go into what it says, just to follow the steps I say:
                (solar_env)$  brew install pkgconfig
                (solar_env)$  brew install git
matplotlib:
                Download  zip file from  https://github.com/matplotlib/matplotlib
                      (solar_env)$  pip install ~/Downloads/matplotlib-matplotlib-v1.1.0-443-gbf81821.zip  # zip file downloaded
                 Also, you could use pip and git directly using:
                      (solar_env)$  pip install git+https://github.com/matplotlib/matplotlib.git # (I have not tried)
                 In any case: matplotlib => INSTALLED!!!!
pyfits
                (solar_env)$  pip install pyfits

Next packages seems optional, or that's what it says in the page.  As I've not sure how optional they are, I've installed them all.
PYQT [optional]
       Install Qt (I used brew, so everything is compiled.  ATTENTION! it takes quite a while, I left it after couple of hours and it was done next morning.
                (solar_env)$  brew install qt  # I had to run it twice... first time an error related with a patch appear, but it worked fine the second time I run it.
                (solar_env)$  brew install qt  # yes! this is the second time!  And the one that takes forever! but it does work at the end ;-)
       Install SIP.
                Download it from:  http://www.riverbankcomputing.co.uk/software/sip/download
                (solar_env)$  cd ~/Downloads  # or whenever you have downloaded SIP.
                (solar_env)$  tar zxvf  sip-4.13.2.tar.gz
                (solar_env)$  cd sip-4.13.2
                (solar_env)$  python configure.py
                (solar_env)$  make
                (solar_env)$  make install
      Install PyQT
                  Download PyQT from: http://www.riverbankcomputing.co.uk/software/pyqt/download
                (solar_env)$ cd ~/Downloads
                (solar_env)$ tar zxvf PyQt-mac-gpl-4.9.1.tar.gz
                (solar_env)$ cd PyQt-mac-gpl-4.9.1
                (solar_env)$ python configure.py
                (solar_env)$ make
                (solar_env)$ make install

SUDS [optional]
          Download suds https://fedorahosted.org/suds/
                (solar_env)$ pip install ~/Downloads/python-suds-0.4.tar.gz

OpenJPEG [optional]
                (solar_env)$ brew -v install openjpeg    # this install cmake, libtiff, little-cms2, and  openjpeg! easy!

PIL [optional]
          Downladed pil from http://www.pythonware.com/products/pil/
                (solar_env)$   pip install ~/Downloads/Imaging-1.1.7.tar.gz    # It worked but it says that support for Freetype2 and  littlecms is not available... though it was installed before...  I have not tested if it works properly, but the installation worked fine.

So, finally:

****************************  SUNPY ******************************

Download stable (which is the same that last git) from http://www.sunpy.org/download/
                (solar_env)$   pip install ~/Downloads/sunpy-sunpy-v0.1-275-g6043140.tar.gz  #  => FAILED!

Ooohhh!!! all that for nothing???? nope... and this could be a problem with pip copying the things from the net... because it seems that searches for a file.. "distribute" but it does not download it... but we can do it manually:

Distribute :  
          Download distribute from: http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz
          (solar_env)$   pip install ~/Downloads/distribute-0.6.24.tar.gz

Then, again, and this time YES, finally:
****************************  SUNPY ******************************

                (solar_env)$   pip install ~/Downloads/sunpy-sunpy-v0.1-275-g6043140.tar.gz 

WORKS!!!! so far, I've just run the example on the documentation:
                (solar_env)$   ipython
                In [1]: import sunpy
                In [2]: from matplotlib import cm
                In [3]: from matplotlib import colors
                In [4]: aia = sunpy.make_map(sunpy.AIA_171_IMAGE)
                In [5]: aia.show(cmap=cm.hot, norm=colors.Normalize(1, 2048))

and I can see the wonderful AIA 171 image!!!  I haven't tested any other thing because I wanted to let everyone know that it works ;-)

In resume, it seems a bit long, and convoluted... but it's not that difficult.  Also, I think this could be "easy" to do in a script... or at least would be a good approach as to pack it as a tar file with all the dependencies and distribute it for the different macs.  What does the people think? 

Has anyone got this far of the mail? or I'm writing for myself?  In any case, I will check... when I have another bit of time, to see how easy is to tar the environment (brew and solar_env) and see if it works in a similar computer.

Good and wonderful day to everyone!!!!

David

PS. Please, feel free to give me any comment!!!  we could put this on the documentation, but I prefer to do so once we have tested this method in other macs.
PPS. Part of the info of virtualenv come from this page: http://www.kyle-jensen.com/install-scipy-on-mac-os-x-106



Keith Hughitt

unread,
Mar 5, 2012, 9:07:43 AM3/5/12
to su...@googlegroups.com, Peter Gallagher
Hey David,

Thanks for putting this together! I know a lot of people have been having trouble installing different libraries on OS X, so trying out different methods and finding a simple approach would be very useful.

Alex was looking into a third method of setting things up on OS X. Perhaps once he has gone through that and shares his experience we can decide which of the approaches would be the best one to include in the SunPy docs.

Cheers,
Keith





--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To post to this group, send email to su...@googlegroups.com.
To unsubscribe from this group, send email to sunpy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sunpy?hl=en.

Reply all
Reply to author
Forward
0 new messages