pythonpython-2.7buildroot

Where can I get the Python 2to3 library on Buildroot


I get the following error when importing gmusicapi in Python 2.7 on a Buildroot Linux system:

>>> import gmusicapi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gmusicapi/__init__.py", line 4, in <module>
    from gmusicapi.clients import Webclient, Musicmanager, Mobileclient
  File "gmusicapi/clients/__init__.py", line 4, in <module>
    from gmusicapi.clients.webclient import Webclient
  File "gmusicapi/clients/webclient.py", line 5, in <module>
    from past.builtins import basestring
  File "past/__init__.py", line 88, in <module>
    from past.translation import install_hooks as autotranslate
  File "past/translation/__init__.py", line 41, in <module>
    from lib2to3.pgen2.parse import ParseError
ImportError: No module named lib2to3.pgen2.parse

Python can't find lib2to3. Neither can I ;-). Is there anywhere I can download this library? I'm using Buildroot, so I can't simply do pip installs.

This is not a duplicate of: How to use/install python 2to3?


Solution

  • lib2to3 is a standard library, normally included with Python. However, the buildroot build system explicitly removes it.

    I'm not certain if Buildroot actually lets you disable their patch; the python.mk file appears to hardcode the flag:

    PYTHON_CONF_OPTS += \
        --without-cxx-main \
        --without-doc-strings \
        --with-system-ffi \
        --disable-pydoc \
        --disable-test-modules \
        --disable-lib2to3 \
        --disable-gdbm \
        --disable-tk \
        --disable-nis \
        --disable-dbm \
        --disable-pyo-build \
        --disable-pyc-build
    

    and I don't see an option to add --enable-lib2to3 to override that. You may want to check with the Buildroot community if this is at all an option. Otherwise, I'd just edit that make file.