Posts for the 'OSX' Category

  1. psycopg2 OS X – _PQbackendPID

    If you are having problems with _PQbackendPID, psycopg2 and OS X and have tried the forcing to 32 bit mentioned in other posts about the web then it might be time to try a more forceful approach. This is an example of the error that you might face:

    dlopen(/Library/Python/2.6/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
      Referenced from: /Library/Python/2.6/site-packages/psycopg2/_psycopg.so
      Expected in: flat namespace
     in /Library/Python/2.6/site-packages/psycopg2/_psycopg.so

    The first thing to do is get rid of your old Psycopg2 (just in case), so locate the site-packages directory:

    python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

    Then in that directory:

     rm -rf psycopg*

    Then remove the old version of PostGreSQL as much as possible. Not sure what version you might have installed, but if you have pg_config on your sys path it will tell you where it is. These instructions may or may not work for you:

    1. Stop the server. sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-8.4.plist
    2. Remove the plist file
      sudo rm -f /Library/LaunchDaemons/com.edb.launchd.postgresql-8.4.plist
    3. Remove the Applications Menu.
      sudo rm -f “/Applications/PostgreSQL 8.4″
    4. Remove the installation directory
      sudo rm -rf /Library/PostgreSQL/8.4
      (Note: You can backup your data directory in case you need it.)
    5. Remove the ‘postgres’ user
      sudo dscl . delete /Users/postgres
      (Note: This step is optional)
    6. Remove the ini file
      sudo rm -f /etc/postgres-reg.ini

    I found a reboot worked to make sure that we are back to normal and nothing is installed.

    Download psycopg2-2.2.1.tar.gz
    Download PostGreSQL from http://www.enterprisedb.com/products/download.do – the version that isn’t the “Standard Server” but just “PostgreSQL 8.4 ” – you do have to register for that.

    Install Postgresql – making sure that it completes, if not it means that you probably had some old files or users in there. If it went ok it should have installed and started running on port 5432. Try removing it /Library/PostgreSQL/8.4/uninstall-postgresql.app – and then removing the user or files that it complained about.

    Download and install http://www.python.org/download/releases/2.6.5/ Mac Installer disk image. Restart (not sure that this restart is totally needed, but I did it anyway).

    Now when you are on a new terminal window and type “python” it should say version 2.6.5. You will have to reinstall any python bits and pieces that you have installed previously – but make sure that you reinstall PIP and easy_install – they will use the old version of Python if you are not careful.

    Now go into the directory of psycopg2-2.2.1 that you downloaded earlier.

    Change setup.cfg so it looks like the following:

    [build_ext]
    define=PSYCOPG_EXTENSIONS,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3

    # PSYCOPG_EXTENSIONS enables extensions to PEP-249 (you really want this)
    # PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower)
    # HAVE_PQFREEMEM should be defined on PostgreSQL >= 7.4
    # HAVE_PQPROTOCOL3 should be defined on PostgreSQL >= 7.4
    # PSYCOPG_DEBUG can be added to enable verbose debug information
    # PSYCOPG_OWN_QUOTING can be added, but it is deprecated (will go away in 2.1)
    # PSYCOPG_NEW_BOOLEAN to format booleans as true/false vs 't'/'f'

    # Set to 1 to use Python datatime objects for default date/time representation.
    use_pydatetime=1

    # If the build system does not find the mx.DateTime headers, try
    # uncommenting the following line and setting its value to the right path.
    #mx_include_dir=

    # For Windows only:
    # Set to 1 if the PostgreSQL library was built with OpenSSL.
    # Required to link in OpenSSL libraries and dependencies.
    have_ssl=0

    # Statically link against the postgresql client library.
    static_libpq=0

    # "pg_config" is the preferred method to locate PostgreSQL headers and
    # libraries needed to build psycopg2. If pg_config is not in the path or
    # is installed under a different name uncomment the following option and
    # set it to the pg_config full path.
    pg_config=/Library/PostgreSQL/8.4/bin/pg_config

    # If "pg_config" is not available, "include_dirs" can be used to locate
    # postgresql headers and libraries. Some extra checks on sys.platform will
    # still be done in setup.py.
    # The next line is the default as used on psycopg author Debian laptop:
    #include_dirs=/usr/local/lib

    # Uncomment next line on Mandrake 10.x (and comment previous ones):
    #include_dirs=/usr/include/pgsql/8.0:/usr/include/pgsql/8.0/server

    # Uncomment next line on SUSE 9.3 (and comment previous ones):
    #include_dirs=/usr/include/pgsql:/usr/include/pgsql/server

    # If postgresql is installed somewhere weird (i.e., not in your runtime library
    # path like /usr/lib), just add the right path in "library_dirs" and any extra
    # libraries required to link in "libraries".
    library_dirs=/Library/PostgreSQL/8.4/lib
    libraries=/usr/lib

    Now run the installation using the new python:

    python setup.py install

    This should install. You should be able to do “import psycopg2″ from the python prompt. Now install all the libraries and python modules that you need, and create the Postgresql database that you want (pgadmin3 is the best tool for this).

    Please note this was done on a OS X Snow Leopard 10.6.4 with XCode and the 10.4 libraries installed.

    By timc3 on the
    August 20th, 2010
  2. NewNewsWire

    I have posted about NetNewsWire many times on here before. Its been my favourite news reading application for a couple of years now (if not more) but recent development has severally hampered the usability of the software.

    It seemed to be when they changed it to support sync to Google Reader – not a bad idea by any means, but releasing the software before it was full tested and working was a huge mistake. Trying to push it to people before it was ready was an even bigger mistake.

    Now twitter & fb are full of messages about problems with the Mac OSX and iPhone version, and it really needs to be sorted out. I know its free now, but as I have said before I paid for it a long time ago and it worked, if its a question of money then release it as a paid version. Not too expensive ( VersionsApp – take note ) but working.

    Do not recommend it at the moment, which is such a pity as it used to be one of my favourite applications.

    By timc3 on the
    October 9th, 2009
  3. The beauty of the ssh config file

    This is a tip that I have used on OS X and on Linux, which I presume works on other *nix and BSDs using SSH.

    Basically in the .ssh folder in your home directory you can create a file called config with which you can put all sorts of configuration information for your ssh client but the real benefit for me was to use this to give extra information to hosts such as defining a different port number to connect on. For instance:

    Host myservername
            User myuser
            Port 22222

    This means that instead of typing:

    ssh -p 22222 myuser@myservername

    I can type:

    ssh myservername

    No need for nasty aliases in the shell or anything like that. This also works for the sshfs program on the Mac that makes use of MacFuse. Yes that’s right you can use different ports with SSHfs.

    You can also change a much wider range of parameters than I have shown here, but often its probably better to introduce them on the server. But here is an example and have a look under the options flag in the Man page for SSH

    Compression yes
    CompressionLevel 9
    FallBackToRsh yes
    KeepAlive no
    By timc3 on the
    September 4th, 2009
  4. PostgreSQL for Mac and language support – PLPGSQL

    Seems sometimes the PostgresqlforMac package doesn’t have support out of the box for PLPGSQL or other stored procedure languages and you can’t simply change to the correct user to upgrade it instead call the createlang command like this:

    /Library/PostgreSQL8/bin/createlang -l DATABASE -U USER;

    Obviously changing DATABASE to your database and USER to your user. This will list all the languages enabled for that database.

    To add PL/PGSQL, try this:

    /Library/PostgreSQL8/bin/createlang plpgsql DATABASE -U USER;

    Now you are free to create your functions.

    If you want to save the change for each database that is created, apply the change to template1 database.

    By timc3 on the
    May 26th, 2009
  5. Installing Windows 2008 on MacBook Pro 10.5

    Windows 2008 Server is probably the most robust operating system to come out from Microsoft whilst still supporting most of the modern features users demand. The robustness and speed of it is just two of the advantages it has over Vista.

    To install on a MacBook Pro its probably easiest to use Windows 2008 Server x86 CD 32bit. 64Bit and bootcamp is not recommended at the moment!

    First steps of the installation:

    1. Step one is to start up the bootcamp assistant whilst you are running OS X.
    2. It will take you through the procedure
    3. Put in the DVD when prompted
    4. Follow through the questions asked for the install
    5. When prompted to enter a password make sure to use one of these three: numbers, symbols, capital letters, lower case letters. Password policy is setup on Windows 2008!
    6. It will continue to install and any reboot needed will take you back to the installation

    After this is done the OS is installed, but as a workstation OS its a bit of pain to use.

    Next steps straight after installation

    1. Start by downloading a webbrowser that you can actually use. IE is quite restricted so to even download something you must go into options and change the privacy options
    2. Insert your Leopard disk and install the drivers that you need, then reboot
    3. From here you can change the resolution of the desktop to the native display resolution

    All the steps after this are optional, but are probably good to know:

    Enable themes

    1. Open up “Server Manager”
    2. Click “Action”, “Add Features”
    3. Choose “Desktop Experience”
    4. Go into the Service panel
    5. Enable the themes service (its probably disabled, so you need to double click it and enable it
    6. Select a theme by right clicking on the desktop and selecting personalised
    7. Aero theme can be found at:
      C:\Windows\Resources\Themes

    Enable wireless networking

    1. Open up “Server Manager”
    2. Click “Action”, “Add Features”
    3. Choose “Wireless LAN Service”
    4. Let it install

    Enable hibernation

    1. Open up a command prompt and type
    2. powercfg.exe /hibernate on

    For more information on turning Windows 2008 into a workstation check out:

    http://www.win2008workstation.com/wordpress/

    And for a program that easily enables the features of a workstation on Windows 2008 server:

    http://www.win2008workstation.com/wordpress/2008/07/17/windows-server-2008-workstation-converter/

    By timc3 on the
    February 7th, 2009
  6. Working with SVN on OS X

    I use SVN (subversion) quite a bit, even at home to manage my own files, but recently I have been running the beta version for Versions by Sofa and Pico.

    It turned into an excellent way of using SVN, being very visual and supporting everything that I needed, but alas the Beta period ran out and they released Versions 1.

    Now I was all for buying this application, but the purchase price of 39 Euros totally puts my of. After all this is a nice to have, and only improves my life slightly. It just doesn’t seem worth the price – particularly when most software like this for OS X is about half the price (I would have easily decided to buy it for 20 Euros).

    So after deciding whether to hack it, not really an option any more as I like to have all paid for or properly licensed software on my machines, or search for something else I looked back at what I could use.

    SVN from the command line. So I started using this again, and I found myself checking in versions of things that are not ready and not having a nice overview of files. It works of course, but it didn’t suit my way of working since using versions – checking in some files, and generally knowing the status of projects that I am working on.

    Then I went back to the SVN plugin for Finder. This is ok, but more often than not the rendering of icons showing whether a folder is up to date or not stops working leaving me in the dark.

    Then I decided to check out textmate SVN integration. Its ok, but not really good enough, I don’t like the keybindings and the interface is not intuitive enough.

    Finally I came across the ProjectPlus plugin for Textmate. After installing just configure it in the preferences to work with what ever source revision system you use (Its supports SVN, Git, Mercurial, Svk & Bazaar), and you can see the state of what you are doing in the system.

    By timc3 on the
    January 10th, 2009
  7. 2008 Applications of the year

    So here are my most used OS X applications of the year, in no particular order:

    * Spotify. This is just an excellent music application, the speed with which the streams start is simply amazing and I don’t find that I get that many adverts in the way of the vast array of songs on offer.

    * Textmate. I probably use this more than any other application on the Mac, for me hands down the best text editor that I have ever used and I find more and more features in it everyday.

    * NetNewsWire Pro. Having all my RSS feeds in one place is really just what I need. Must remember to integrate it with FriendFeed.

    * Adium. Always there, some times a pain with XMMP but otherwise just awesome.

    * Python 2.5. Best scripting language by far, but then I am biased.

    All free (I did buy a license for NetNewsWire but you no longer have to) apart from TextMate which is more than worth the price.

    By timc3 on the
    January 9th, 2009
  8. Last FM

    I recently thought that I would check out my listing on Last FM to see stats etc.. and to see what features they have added.

    Looks like I had forgotten to run last.fm on my Mac so it wasn’t updated since February. So that’s probably about 1000 hours of music unlisted, and lots of music missing. Gutted. Oh well, perhaps I will remember now.

    By timc3 on the
    October 10th, 2008
  9. My top ten OS X applications

    Its been a year with this Mac Book Pro that I am using so I thought that I would round up with my top ten Mac software – the software that I would install first of all after a crash.

    1. Quicksilver. This is a must have on the Mac. I find out something new about it every week if not everyday and it makes using OS X even easier and more streamlined. For instance, finding a contact and then sending an SMS through skype can be achieved in a few keystrokes, far faster than clicking around in the GUI.

    2. NetNewsWire Pro. Now free to download, I had a paid version of this and its the best way to read newsfeeds that I have come across. It syncs with a web version so I can still access the my newsfeeds when I am away, and there are clients for other platforms including Windows Mobile.

    3. Knox. I use this to keep all my important documents and things that I don’t want to go missing. It backups to my USB thumbdrive everyday, and its easy to backup online.

    4. SSHFS and MacFuse. Easy easy way to mount external SSH shares onto the desktop.

    5. Address book, Apple Mail and iPhoto. At first I stayed away from the integrated applications, but they are REALLY integrated, and work so well together the extra functionality that you get from using them together is well worth the switch.

    6. Adium. The best chat client that I have found for instant messaging on OS X. It doesn’t have all the features that individual applications might have (voice and webcam for one). But sometimes you just don’t need that, and really skype running along side is better for this. If it had all the features of skype it would be really the true all rounder.

    7. Unison. I use Usenet alot. Its a great news client. Perhaps the best on any platform at the moment.

    8. Textmate. Perhaps the best editor on OS X – I tried many until I paid up and bought Textmate. Its strong bundles and integration with svn plus the nice support for Django wins for me.

    9. MarsEdit. Great blog posting tool.

    10. Versions. This is quite new but it makes working with SVN just a little easier.

    By timc3 on the
    July 21st, 2008
  10. Installing ffmpeg on OS X

    This is a work in progress for installing ffmpeg on OSX by a custom compile

    This is another thing that I have needed to do and decided to put what I am doing in a blog post, I might need it in the future or it might be helpful for others.

    So firstly download LAME – this is needed for supporting MP3 audio files, such as those in FLV and also for vorbis support. LAME src can be located on sourceforge.

    Unarchive the file (lame-3.98b6 at the time of writing )

    cd lame-3.98b6
    ./configure --with-vorbis
    make
    sudo make install

    The first time I did this I noticed a problem running make so I “make clean” and then went through the process again.

    Next up we want support for AAC audio, and you can get packages called FAAD2 and FAAC from www.audiocoding.com/downloads.html for these and then unarchive them ( FAAD 2.6.1 and FAAC 1.26 at the time of writing).

    cd faad2
    autoreconf -vif
    ./configure --without-bmp --without-xmms --without-drm --without-mpeg4ip
    make
    sudo make install

    Then faac

    cd faac
    ./bootstrap
    ./configure --with-libmp4v2
    make
    sudo make install

    x264 ( http://www.videolan.org/developers/x264.html )

    cd x264
    ./configure --enable-pthread --enable-pic
    make
    make install

    liba52

    wget http://liba52.sourceforge.net/files/a52dec-snapshot.tar.gz
    tar -xzvf a52dec-snapshot.tar.gz
    cd a52dec-0.7.5-cvs/
    ./configure
    ./configure --enable-libmp3lame --enable-x264 --enable-liba52 --enable-gpl

    And for amr_wb and amr_nb go into their directories and do the following:

    ./configure
    make clean
    make -j2 > /dev/null
    sudo make install

    Basically the -j2 switch is for enabling dual cores when compiling.

    Now we get around to compiling ffmpeg itself:

    ./configure --enable-shared --disable-mmx --enable-libmp3lame --enable-libamr-wb --enable-libamr-nb --enable-nonfree --disable-vhook
    make clean
    make -j2 > /dev/null
    sudo make install

    And that should be it though I am currently trying this configuration and it seems to work well:

    ./configure --enable-shared --disable-mmx --enable-libmp3lame --enable-libamr-wb --enable-libamr-nb --enable-nonfree --enable-libx264 --enable-libfaad --enable-gpl --disable-vhook
    By timc3 on the
    March 25th, 2008