zc.buildout stopped working: ImportError: No module named apport.fileutils
Asked Answered
S

2

11

I've been using buildout for quite a while now without any issue, in fact I did yesterday without any problems.

But as today all my projects fail to buildout. I tried on two different Ubuntu workstations with the same result.

This is the error I get:

Initializing zc.buildout
Debug: Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
  File "bootstrap.py", line 259, in <module>
    import zc.buildout.buildout
  File "/tmp/tmpNkVMXW/zc.buildout-2.0.0-py2.7.egg/zc/buildout/buildout.py", line 18, in <module>
    import zc.buildout.easy_install
  File "/tmp/tmpNkVMXW/zc.buildout-2.0.0-py2.7.egg/zc/buildout/easy_install.py", line 59, in <module>
    pkg_resources.Requirement.parse('distribute')
AttributeError: 'NoneType' object has no attribute 'location'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
ImportError: No module named apport.fileutils

Original exception was:
Traceback (most recent call last):
  File "bootstrap.py", line 259, in <module>
    import zc.buildout.buildout
  File "/tmp/tmpNkVMXW/zc.buildout-2.0.0-py2.7.egg/zc/buildout/buildout.py", line 18, in <module>
    import zc.buildout.easy_install
  File "/tmp/tmpNkVMXW/zc.buildout-2.0.0-py2.7.egg/zc/buildout/easy_install.py", line 59, in <module>
    pkg_resources.Requirement.parse('distribute')
AttributeError: 'NoneType' object has no attribute 'location'

It complains that there's no module named apport.fileutils .. but I get no exception when I run python and import it:

from apport.fileutils import likely_packaged, get_recent_crashes
Silverfish answered 10/2, 2013 at 19:0 Comment(0)
T
24

2.0.0 just got released. The old bootstrap.py is not compatible with 2.0.0 but downloads it by default. You can get the v2 bootstrap.py from here, or use the code below if you want to stick with the old version.

python bootstrap.py -v 1.7.0

edit: older versions of v1 bootstrap.py don't allow version forcing. The up-to-date version here does.

Topper answered 10/2, 2013 at 19:18 Comment(2)
Thank you, that worked. I initially though I would upgrade buildout to 2.0 .. but it seems to breaks a lot of extensions so I'll stick with 1.7 for a while I think.Silverfish
I just ran into the same problem, thanks for your helpful answer! Relates also to: #14817638Realism
P
0

The question + answer is from 2013. I recently (2015) saw it happening again.

The problem is that ubuntu's python-apport package installs a /usr/lib/python2.7/dist-packages/apport_python_hook.py file that overrides sys.excepthook. It makes sure python tracebacks are fed into ubuntu's "apport" error reporting mechanism.

That in itself is not a problem. But bootstrap.py restricts the python path, so that the hook cannot import apport anymore...

So if an error occurs during the bootstrap run, an exception is printed which then fails a second time because apport cannot be imported.

A solution could be to sudo apt-get remove python-apport. That's at least what we did on the server (where having apport makes no sense in any case).

Psychogenic answered 7/12, 2015 at 9:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.