mozilla-services / syncserver

Run-Your-Own Firefox Sync Server
Mozilla Public License 2.0
1.87k stars 145 forks source link

ImportError: cannot import name ConverterMapping #153

Open julienschmidt opened 5 years ago

julienschmidt commented 5 years ago

I migrated my syncserver from a Debian Stretch to a Debian Buster host and WSGI suddenly starts to fail:

Traceback (most recent call last):
  File "syncserver.wsgi", line 40, in <module>
    application = loadapp('config:%s'% ini_file)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 271, in loadobj
    global_conf=global_conf)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
    global_conf=global_conf)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
    return loader.get_context(object_type, name, global_conf)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 454, in get_context
    section)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 476, in _context_from_use
    object_type, name=use, global_conf=global_conf)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 406, in get_context
    global_conf=global_conf)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
    global_conf=global_conf)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
    return loader.get_context(object_type, name, global_conf)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 620, in get_context
    object_type, name=name)
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
    possible.append((entry.load(), protocol, entry.name))
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2302, in load
    return self.resolve()
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2308, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "./syncserver/__init__.py", line 18, in <module>
    import mozsvc.config
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/mozsvc/config.py", line 10, in <module>
    from konfig import Config, SettingsDict
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/konfig/__init__.py", line 11, in <module>
    from configparser import ConfigParser, ExtendedInterpolation
  File "/var/fxcloud/syncserver/local/lib/python2.7/site-packages/configparser.py", line 12, in <module>
    from backports.configparser import (
ImportError: cannot import name ConverterMapping

If I edit the requirements.txt as follows:

-configparser==3.5
+configparser==3.5.0b2

and rebuild the env, it suddenly starts to work. The same version (90d8e83) works fine on the Debian Stretch host without any modifications. I further tried to add the pip flag --no-cache-dir and copying the already built env from the old host, both leading to the same error.

I'm a bit out of ideas why this might fail. The diff between 3.5.0b2 and 3.5.0 is not big, but it does include some changes regarding ConverterMapping: https://bitbucket.org/ambv/configparser/branches/compare/78998f2..3005b52#diff

rfk commented 5 years ago

This is a strange one. It looks like the ConverterMapping class is new in the 3.5.0 version of the module, so I wonder your new setup is somehow using an outdated version of backports.configparser. In the virtualenv, if you just import backports.configparser and inspect the resulting module, does it give any indication that it might not be using the correct version? Example from my own local install:

$ ./local/bin/python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import backports.configparser
>>> backports.configparser.__file__
'/mnt/c/Users/ryan/Desktop/repos/mozilla-services/syncserver/local/local/lib/python2.7/site-packages/backports/configparser/__init__.pyc'
>>>

What python version are you running on the old build, and the new?

julienschmidt commented 5 years ago

Old (Debian Stretch):

Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import backports.configparser
>>> backports.configparser.__file__
'/var/fxcloud/syncserver/local/local/lib/python2.7/site-packages/backports/configparser/__init__.pyc'
>>>

New (Debian Buster):

Python 2.7.15+ (default, Nov 28 2018, 16:27:22)
[GCC 8.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import backports.configparser
>>> backports.configparser.__file__
'/var/fxcloud/syncserver/local/local/lib/python2.7/site-packages/backports/configparser/__init__.pyc'
>>>