Installing MatPlotLib on OS X for Python Version 2.6.1 with PIP and VirtualEnv

If you thought you had installed matplotlib only to find this

File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/__init__.py", line 166, in
__import__('ma', g, l)
File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/ma/__init__.py", line 16, in
from numpy.core.ma import *
ImportError: No module named ma

It is because the package being installed is version 0.91 and you need at least version 1.0 .

If it’s already installed pass pip the upgrade flag and specify the package location with the “-f” flag

pip install --upgrade -f http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz matplotlib

If not installed

pip install -f http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz matplotlib

Resources:

http://stackoverflow.com/questions/3555551/why-does-pip-install-matplotlib-version-0-91-1-when-pypi-shows-version-1-0-0

Installing and Using Rvm on Mac OS X, Creating Gemsets and Reverting to Original Environment

What is RVM and why should you use it? RVM is a Ruby interpreter, version management tool. In short, it enables you to switch between different versions and releases of Ruby (for instance, version 1.8.6, 1.8.7, jruby 1.9.2, ruby enterprise edition) on the same machine, while associating different gems with each version of the ruby interpreter. This is super useful and awesome. If you want to play with Rails 3 and Ruby 1.9.1, for 5 minutes, and then want to switch back to your production apps, which are running on Rails 2.3.5 and Ruby 1.8.7, you can do so with a single command from the terminal. With RVM this is a fairly simple process so there is no reason not to install it. You can also revert back to your system settings (not using RVM) with a single command. After all Rails is just a gem, so you can easily create and manage different RVM “gemsets”, (sets of different gems), for the different versions of Ruby (rubies as RVM refers to them) you have installed.

Installing RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Next you have to add rvm to your bash profile

# place in ~/.bash_profile as the very last line
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

To check everything went well

type rvm | head -n1

Should tell you “rvm is a function”

How to add ruby, pass it the version to install

rvm install 1.8.7

*The current terminal session will load this environment. New sessions will not. To use a version of ruby and set it as the default, pass it the –default option

rvm use 1.8.7 --default

Next create a gemset, which will make available different gems for different versions

rvm gemset create rails_2_3_5

When you run “gem list”, you should see nothing!

gem install rails -v=2.3.5

Set a default rvm and default gemset, specify which gemset with the @ sign and include the –default option

rvm use 1.8.7@rails_2_3_5 --default
which gem
gem list
ruby --version
rails --version

And to get back to where you started and revert to using your original ruby setup

rvm system

For upgrading your version of RVM check out this post I wrote http://seanbehan.com/ruby/how-to-upgrade-rvm-on-mac-os-x/

Finally, you can create a .rvmrc file and put it in any directory and when you cd into that directory the environment specified in the file will be loaded automatically. This way you don’t have to remember the version and gemsets and type them into the console. All you have to do is put the ruby version and gemset name in the file like so

ruby1.8.7@rails2.3.5

You’ll be prompted to trust the .rvmrc file the first time, type “y” for yes. Also, subdirectories will inherit this .rvmrc so you can just put it in the parent directory like

rails2/
     .rvmrc
     app1
     app2
rails3/
     .rvmrc
     app1
     app2

And both app1 and app2 will use the .rvmrc environment while your rails3 directory apps will load the environment in its directory!

More information available here:
http://rvm.beginrescueend.com/rvm/install/
http://www.stjhimy.com/posts/4
http://eddorre.com/posts/installing-rails-3-beta-4-using-rvm

7 Dec 2009, 9:34pm
Linux mac os x:
by

1 comment

Updating Your Twitter Status with cURL and a Bash Function

I’m usually at the command line so I wrote a little a bash function so that i can type

tweet this is really neat but kind of pointless

and it will update my twitter status! some characters trip it up but in general it’s useful for most of my tweets. The tweet function just spits out the arguments passed to it for the status parameter for the API call to twitter.

Add the following to the .bash_profile file and reload the terminal (don’t forget to add your email and pwd where appropriate).

tweet() {
   curl -u your_twitter_email_addr:your_twitter_passwd -d status="$*" http://twitter.com/statuses/update.xml
 }
 

*** Twitter still uses http basic authentication for their API. However, they are moving away from it in favor of oAuth. So I’m not sure how long this fun will last :{

Disk Usage Information on Mac OS X

Get disk usage information about the Desktop

$ du -h -d 0 Desktop
14G	Desktop

Information about how much free space is available on computer

$ df -lh
Filesystem     Size   Used  Avail Capacity  Mounted on
/dev/disk0s2  111Gi  109Gi  2.3Gi    98%    /

You can read more about the flags with the man pages

$ man du
$ man df

This is my 100th post!!!