Total Pageviews

Friday, September 20, 2013

How to Kill an App in iOS 7

It's almost the same as before,  just a tad faster:
  1. Double click the home button
  2. Swipe to the troublesome app
  3. Swipe it up an out of there!
And that's that!

Hopefully this saves you some frustration when switching to iOS 7 and you're wondering, "What the heck? I can't kill a troublesome app anymore!?"

Yes, yes you can.

Wednesday, September 04, 2013

Updating Python Scientific Computing Environment on Mac OS 10.8

Upgrading an OS is simultaneously awesome and terrifying. Awesome because you are about to get your hands on what, hopefully, will be some fantastic new features! Terrifying because the upgrade will likely break a lot of software on your system, especially development tools.

Ooo, I'm intrigued! But is it safe?
(image from here)

In my case, I had a pretty good feeling the upgrade from Snow Leopard to Mountain Lion would break many parts of the python scientific computing development environment running on my system. Fortunately, I was going take a hiatus from that kind of development for a while. When I finally picked it back up, everything was working fine, surprisingly! But then I needed to update Pandas and iPython...

My development environment was built using Homebrew and pip. It's got python, zeromq, numpy, scipy, matplotlib, cython, pandas, ipython, and qtconsole. If you are looking to create an the environment from scratch, check out this article. It's pretty good. At some point I'll write up what I did. This article focuses on updating your installation.

Happy Path to Updating


My particular installation has a few more packages installed. So, there are more updates that need to occur. Note that when doing some of the upgrades via pip, other upgrades may get automatically triggered. For instance, upgrading matplotlib will likely upgrade tornado; therefore, you would not need to do so explicitly.
  01  brew update                             # update brew itself
  02  brew upgrade                           # update all installed packages
  03  pip list                                     # list installed pip packages
  04  pip install --upgrade numpy
  05  pip install --upgrade scipy
  06  pip install --upgrade matplotlib   # will likely update tornado for you
  07  pip install --upgrade cython
  08  pip install --upgrade pandas
  09  pip install --upgrade pyzmq
  10  pip install --upgrade pygments
  11  pip install --upgrade ipython      # repeat 'til latest version is installed
  12  pip list
  13  ipython qtconsole                    # test ipython in the GUI
  14  ipython                                   # test ipython in the terminal

Errors Updating Homebrew


Now, it is very likely that the happy path did not work so smoothly (ah, gotta love updates). Firstly, you may have encountered issues with updating homebrew. Oh I don't know, maybe you saw something that said error: unable to unlink old '.gitignore' (Permission denied), and several more like it. It kinda looks like this:


Or maybe you got some error stating that Your local changes to the following files would be overwritten by merge. See my post on Updating Homebrew Woes for tips on dealing with various issues. I am going to be brief here. The following commands should solve your Homebrew issues, and you can start on the happy path again.
  01  brew doctor
  02  sudo chown -R $(whoami) $(brew --prefix)
  03  cd $(brew --prefix)
  04  git fetch origin
  05  git reset --hard origin/master
The brew doctor command will tell you nearly everything that is wrong. Listen to the doctor and do what she says. The chown command will make sure you, the local user, owns the directory in which brew lives. The last three will reset your brew installation to the master branch (so, if you did actually make local changes, you may want to commit them).

Errors Updating PIP Installed Packages


You may have, or will, encounter numerous issues here. Some of them will result from not having updated Xcode and/or Command Line Tools for Xcode (see Updating Homebrew Woes for details). Here are a few errors you may encounter and solutions:

       error: /usr/include/zlib.h: No such file or directory

          ➜   install/update Xcode and/or Command Line Tools for Xcode

       src/_png.cpp:23:13: fatal error: 'png.h' file not found

          ➜   brew install libpng

       various errors installing matplotlib

          ➜   brew install freetype
          ➜   brew install libpng


Nifty Tools


The brew outdated command will list all installed packages that have available updates. So, you can use this command to estimate how much updating you will be doing, and how much time you might have to devote to this endeavor.

Unfortunately, pip does not have a similar command. However, Artur Siekielski wrote a script that can tell you what pip packages are up-to-date or have available updates. I have not used the script, but it could be handy.

References + Links

Installing Scientific Python on Mac OS X
Updating Homebrew Woes
Homebrew Troubleshooting
Homebrew FAQ
Script to Check for Package Updates on PyPi

http://pandas.pydata.org/
http://ipython.org/
http://brew.sh/
http://www.pip-installer.org

Tuesday, September 03, 2013

Tips for the Updating Homebrew Woes

Sometimes you run into something that requires you to update your installed packages. And then... you groan. Why? Because you know that once you attempt to update something, a gigantic can of worms will BURST open. Aaaand you know you are about to sink 3-5 hours updating packages, fixing dependencies, the whole nine.


To update brew and installed packages, you usually should only have to do the following commands (1):
1  brew update    # updates brew itself
2  brew upgrade  # upgrades all brew installed packages to latest versions
If you are lucky that day, it will work without a hitch! If not, here are some tips:

0.  The doctor is your best friend


Issue the "brew doctor" command. The doc will tell you what's wrong. Heed the doctor's orders and it will go a long way to reduce frustration.

1.  Make sure your brew --prefix directory is owned by you


At some point, something will mess with the ownership and permissions on this directory (typically /usr/local) and brew will be unable to write to it. The following command will usually remedy the problem (2):
1  sudo chown -R $(whoami) /usr/local
This command will run as super user and recursively change ownership of that directory and its contents to you, the local user.

2.  A hosed brew installation should be reset


Your brew installation may just be completely screwed from the onset. For instance, when you attempt a brew update you may get an error stating (among other things) that "The following untracked working tree files would be overwritten by merge." In this case, reset your brew installation to the master (3):
1  cd $(brew --prefix)
2  git fetch origin
3  git reset --hard origin/master

3.  Update your Xcode installation and/or Command Line Tools for Xcode (CLT)


Homebrew depends on stuff Xcode/CLT installs. Other packages Homebrew installs depend on stuff Xcode/CLT installs. Updating it is usually a good idea. If you do this by installing Xcode, you still have to do a few more things:
  1. Install Xcode from the App Store
  2. Launch Xcode
  3. Accept the License Agreement (most important step, otherwise Xcode is a dud)
  4. Go to Preferences > Downloads
  5. Install/Update Command Line Tools
If you see a message like "error: /usr/include/zlib.h: No such file or directory" when brewing, that usually means you didn't do steps 2-5 listed above. Get at it.

I hope these tips save some of you a bit of time and hours of your life back!

Sources / References

1. Homebrew FAQ
2. Homebrew Troubleshooting
3. Reverting to Master Branch

Good Links

Homebrew Troubleshooting
Homebrew and Python
Homebrew Homepage