Tag Archives: Packages

Things I Forget: Installing new python packages on Windows

I can never remember how to do simple things, be it in Python, R, or Java (hope I don’t have to do too much more work in Java…).   Given that, I plan to post these kind of things, when I remember of course, under the title of “Things I Forget”.  My primary aim for this is to help myself, but I do hope others with a similar memory affliction will also find these useful.

For this first installment: How do you add new python packages from a tarball (i.e. .tgz or .tar.gz file) on Windows?

The Steps:

  1. Hope there is a windows installer.  Given how unlikely this appears to be, move to step 2
  2. Download the tarball.  This is the thing you always see when you are expecting to find the windows installer.  It has some name followed by a .tar.gz or a .tgz.  For instance, if you want to add the ability to write out Excel files (by the way,  I am not advocating for Excel), then you could use the xlwt package.   I usually download these files directly into my into my site-packages directory (C:/Your Python Path/Lib/site-packages).
  3. Once you download the taball you need to find someway to extract the file.  On linux machines this is easy.  I had a bit more of challenge getting it to work on a windows machine.  There are a few options.  I have used PowerArchiver before, but it costs.  Cygwin can do it, but that may be overkill.  The one I have used most recently is the very simple TarTool.  It is free and doesn’t need to be installed, only extracted.  I also keep the TarTool.exe in my site-packages directory.  So, now that I have my tool to extract the file and the file itself, I simply do the following (click for full size):
    tartoolDOS
  4. Now you will have a directory for the package, so to install it is simply a matter of changing into that directory and running the setup.  Just like this (click for full size):
    setupPythonPackage
  5. Your python package is now ready to roll and can be imported (click for full size)!
    testPythonPackage

As an aside, anyone know of a wordpress trick to display a DOS command prompt?  Inserting a screen shot was the best I came up with, but it would be nice to have something akin to the method for highlighting sourcecode.

Advertisements