Search code examples
pythonlibevent

Trying to install an old python app, getting a libevent error


There is an old python app that I want to install on ubuntu.

When I run:

python setup.py install

I get this error:

/tmp/easy_install-s6CQJl/event-0.4.2/setup.py:23: UserWarning: Could not find libevent
  warnings.warn("Could not find libevent")
event.c:4:20: fatal error: Python.h: No such file or directory

I have installed

build-essential
python-setuptools
libevent-dev

Is there something else I am missing?


Solution

  • event.c:4:20: fatal error: Python.h: No such file or directory
    

    It looks like you need the Python development headers. Try

    sudo apt-get install python-dev
    

    Edit:

    Hookbox can be successfully installed on Ubuntu 18.04 with a relatively modern Python 2.7. Here's a complete installation process:

    1. Install OS-level dependencies

      sudo add-apt-repository universe  # Required for old libevent
      sudo apt-get update
      sudo apt-get install \
          build-essential \
          libevent1-dev \
          libevent-1.4-2 \
          python \
          python-dev \
          python-setuptools
      
    2. Clone the source code somewhere convenient

      git clone git://github.com/hookbox/hookbox.git
      
    3. Install Hookbox

      cd hookbox
      
      # Ideally we should install Hookbox in a virtualenv
      #
      # Here is one way to do that
      sudo apt-get install virtualenv
      virtualenv env
      source env/bin/activate
      
      python setup.py install
      

      If you use the virtualenv method outlined above you'll be able to run hookbox --help to see that it's working.

      You can exit the virtualenv with deactivate (and still run hookbox by providing an absolute path to path/to/hookbox/env/bin/hookbox) and re-enter it with source path/to/hookbox/env/bin/activate, at which point hookbox should be on your $PATH.

      If you choose not to use a virtualenv you'll need to use sudo python setup.py install here. That's not recommended as you'll be mixing manually installed Python packages with OS-supplied ones.