Search code examples
pythonmysqlangstrom-linux

Angstrom Python errors on import io


I am trying to resolve some dependencies for the MYSQL connector for Python on Angstrom.

From the command line I get the following error:

Python 2.6.6 (r266:84292, Feb 25 2011, 16:50:01)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named io

I thought that IO was a base-level module. It appears to be up-to-date:

# opkg install python-core
Package python-core (2.6.6-ml12.2.6) installed in root is up to date.

Shouldn't IO be available by default, and what can I do to resolve this issue?


Solution

  • Thanks to Padraic Cunningham who lead me on the path to a solution.

    I found that several files, including io.py were missing from the install. Building the Angstrom for the Beagleboard (XM) image from the Angstrom website did not include these files (or subsequent modifications I made deleted them?). I rebuilt Python, keeping the identical version, from the Python source.

    I had to then rebuild the MySQL connector (from MySql/Oracle). (All my other modules including OpenCV continued to work without issue)

    This worked and I am now able to query the database.

    One additional note. Once all the dependencies were resolved, I still could not connect to the database. The problem was that the MySQL connector was assuming a TCP/IP connection rather than file based socket. So I had to add the following to the connection string:

    unix_socket="/tmp/mysql.sock"
    

    Such that the full connection string looked like this:

    cnx = mysql.connector.connect(user='username', password='password', host='localhost', database='dbname', raise_on_warnings=True, unix_socket="/tmp/mysql.sock")