ImportError: No module named six

I’ve a simple yaml to build a python2 application, but it always fails to build with the “ImportError: No module named six” error. The project has a requirements.txt which specifies six, but I have also tried specifying it with python-packages and stage-packages in the yaml, but it always fails the same way. Any ideas?

name: offlineimap
version: 'master'
summary: OfflineIMAP
description: |
  Read/sync your IMAP mailboxes

grade: stable
confinement: strict

apps:
  offlineimap:
    command: bin/offlineimap
    plugs:
      - network

parts:
  offlineimap:
    plugin: python
    python-version: python2
    source: https://github.com/OfflineIMAP/offlineimap.git
    build-packages:
      - gcc
      - g++

It looks like the error here is in the pull stage of snapcraft. When snapcraft runs setup.py it ends up wanting to import six (via an import of offlineimap). You’ll want to ensure you have six setup in the Python environment that snapcraft uses to build offlineimap part.

1 Like

Thanks for the suggestions. I went for this which works, but looks inelegant to me. Any suggestions for improvements?

name: offlineimap
version: 'master'
summary: OfflineIMAP
description: |
  Read/sync your IMAP mailboxes

grade: stable
confinement: strict

apps:
  offlineimap:
    command: bin/offlineimap
    plugs:
      - network

parts:
  setup:
    plugin: python
    python-version: python2
    python-packages: [six]
  offlineimap:
    after: [setup]
    plugin: python
    python-version: python2
    source: https://github.com/OfflineIMAP/offlineimap.git
    build-packages:
      - gcc
      - g++
1 Like

I think what you have is just fine, I agree it’s not pretty but that’s just the nature of the beast.

2 Likes

Hey @popey, sorry for coming late. I’m happy that @sparkiegeek got here earlier, because nothing I tried worked.

His suggestion looks very good to me, and something new to my list of tips & tricks. :slight_smile:

There is a bug here:

If you want the snapcraft.yaml to be in the same project as the source code, even the separate part to install setup deps will find the setup.py and try to install it.

We need a better story for this case.

1 Like

First of all - I’m just started snapcraft learning.

I tried to build offlineimap python example from here:

My snapcraft setup is according to this (Build on LXD or Docker) - I’m using LXD:

I’m running snapcraft with the following command line:

$ lxc exec snapcraft – sh -c “cd $(pwd); snapcraft”

I’m also getting ImportError: No module named six`.

Is this because of

  • problem is not fixed yet?
  • my build setup is affecting this?

Any idea how to fix the example?

Just wondering that if there is known issue to build offlineimap why it is still used as python example?

1 Like

Sorry for the delay. Looks like we need to update the python example. Note that the genuine offlineimap snap is built slightly differently and fixes the ‘six’ issue.

I’ll get the tutorial updated. Thanks.