Thursday, April 03, 2014

ImportError: No module named pkg_resources when trying to use pip on the BeagleBone Black

I've recently been trying to use Python on the BeagleBone Black, for a number of reasons:

  1. I want to learn a new language which could be useful to me in another job in the future (and this job, even better!)
  2. Given all the effort I've put into making our embedded systems work on multiple platforms, I think I've finally got enough infrastructure in place that we can start leveraging other cross platform products to shorten up our development time.
  3. As a scripting language capable of using bindings to other languages, Python should help me create very functional code that doesn't need extremely high performance in a very short amount of time and reduce my development time for complicated tasks.
Unfortunately, like many other things on the BeagleBone Black, things aren't going as well or as simply as you'd think they should at first glance. For starters, the pip package manager for Python isn't installed by default on the BeagleBone Black (at least not as of the 2012.12 image). So, I had to install that first:

opkg install python-pip

When I tried to run the package manager, I ran into the following error:

Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

After Googling around for a bit, I found these questions on Stack Overflow. Apparently you must also have the setuptools package installed in order to be able to use pip because it's not a simple package manager like apt in Ubuntu. It's more like emerge in Gentoo, where it downloads code packages and is capable of compiling them and performing custom installations. Fortunately, there's an opkg package for that:

opkg install python-setuptools

After that was installed, it became a simple matter of finally importing the actual package that I originally wanted that started all of this:

pip install psutil

... the process utils library for Python

No comments: