Skip to content
David Megginson edited this page Aug 25, 2015 · 5 revisions

This article describes how to install libhxl-python on your local computer system. The process will install both the library and a collection of command-line tools.

If you already have Python 2.7+ and pip on your system, the easiest way to install libhxl is simply

pip install libhxl

That will pull in the latest version and all dependencies from PyPi, and the Command line tools will be available on your system immediately. Otherwise, continue with the following ...

Prerequisites

You need to have Python 2.7+ and the setuptools package installed on your system. Visit https://pypi.python.org/pypi/setuptools for instructions on how to install setuptools in your operating system.

If you're using Ubuntu Linux, the following will install setuptools (and Python too, if it's not already there):

$ sudo apt-get install python-setuptools

Download

Download a copy of the libhxl-python package. You have three choices:

  1. Download the latest milestone release from https://github.com/HXLStandard/libhxl-python/releases
  2. Download a zip file of the current state of the master branch (more up to date) from https://github.com/HXLStandard/libhxl-python/archive/master.zip
  3. Clone the git repository using the command git clone https://github.com/HXLStandard/libhxl-python.git

If necessary, unzip the package (you don't need to do that with the git approach).

(Optional) Test

If you are using a Unix-type system (such as MacOS or Linux), change to the directory containing the code, and run the following command:

python setup.py test

Build and install

The script setup.py will install libhxl-python on your system. You may need administrative permissions to run it on your system. In Ubuntu Linux (and possibly other Unix-type operating systems), the following command will install the package ("sudo" is required only for system-wide installation; if you're installing into a Python virtual environment, you can usually omit it):

$ sudo python setup.py install

Confirm

To confirm that the package is installed, run the command hxlcount -h — you should see output like this:

usage: hxlcount [-h] [--sheet [number]] [--strip-tags] [-t tag,tag...]
                [-a tag]
                [infile] [outfile]

Generate aggregate counts for a HXL dataset

positional arguments:
  infile                HXL file to read (if omitted, use standard input).
  outfile               HXL file to write (if omitted, use standard output).

optional arguments:
  -h, --help            show this help message and exit
  --sheet [number]      Select sheet from a workbook (1 is first sheet)
  --strip-tags          Strip HXL tags from the CSV output
  -t tag,tag..., --tags tag,tag...
                        Comma-separated list of column tags to count.
  -a tag, --aggregate tag
                        Hashtag to aggregate.

You are now ready to us the HXL command-line tools on your system.