1

I'm trying to run the scanpypi script - support script of the Buildroot (2017.02) but I'm getting the following error:

Traceback (most recent call last):
  File "./support/scripts/scanpypi", line 52, in <module>
    import setuptools
  File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 12, in <module>
    import setuptools.version
  File "/usr/local/lib/python2.7/dist-packages/setuptools/version.py", line 1, in <module>
    import pkg_resources
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 40, in <module>
    from pkgutil import get_importer
ImportError: cannot import name get_importer

I added the following lines into beginning of the scanpypi script to see sys.path

- import sys
- print(sys.path)

output:

['/home/timo/bldr_lab/buildroot/support/scripts', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

As the pkgutil is in the /usr/lib/python2.7 directory the problem is not path problem.

I have also uninstalled and re-installed python2.7, pip and setuptools but no help.

What could be reason for the ImportError?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
TimoV
  • 23
  • 2
  • 5
  • What happens if you `python -c 'import pkgutil; print(pkgutil.__file__)`? – anthony sottile Mar 19 '17 at 21:23
  • I'm also experiencing this problem. I've tried to debug it with `pudb` but in the debugger it works like a charm. I've tried `scanpypi` on different Linux distros and all show the same behavior. – yegorich Mar 20 '17 at 08:35

1 Answers1

1

This is a bug in Buildroot. It is due to commit 12683184b1969f65680cb7db55b547a620a9860f that introduced the pkgutil.py file in support/scripts. This conflicts with the pkgutil.py from setuptools.

The solution is to rename the pkgutil.py file to something else, and update the imports in the other scripts accordingly. If you do this, please post a patch on the Buildroot mailing list, so everyone can benefit. See the manual for details how to post patches.

Arnout
  • 2,927
  • 16
  • 24
  • Thanks for info. I actually noticed that "pkgutil.py" is in the support/scripts folder today morning. I renamed it and then scanpypi script started to work as expected. – TimoV Mar 20 '17 at 14:00
  • I just left then wondered why the pkgutil.py was in the folder but now I know. Somehow I'm thinking that reporting a bug would be the correct way to get the problem fixed - I'm bit reluctant to touch other's code. Anyway, I'll try to look at this later today. – TimoV Mar 20 '17 at 14:13