ImportError: No module named config on Travis-CI build
Question: I'm having an import error on [Travis builds](https://travis-
ci.org/dzlab/sentimentpy), the error is related to the configuration of flask:

    
    
    from flask import Flask
    
    app = Flask(__name__)
    app.config.from_object('config')
    

On local machine, the flask app run correctly. But on travis here is the error
trace

    
    
    $ nosetests --with-coverage --cover-package=core
    E.........................
    ======================================================================
    ERROR: Failure: ImportStringError (import_string() failed for 'config'. Possible reasons are:
    - missing __init__.py in a package;
    - package or module path not included in sys.path;
    - duplicated package or module name taking precedence in sys.path;
    - missing module, class, function or variable;
    Debugged import:
    - 'config' not found.
    Original exception:
    ImportError: No module named config)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/nose/loader.py", line 414, in loadTestsFromName
    addr.filename, addr.module)
      File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
      File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
      File "/home/travis/build/dzlab/sentimentpy/webapp/app/__init__.py", line 6, in <module>
    app.config.from_object('config')
      File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/flask/config.py", line 162, in from_object
    obj = import_string(obj)
      File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/werkzeug/utils.py", line 426, in import_string
    sys.exc_info()[2])
      File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/werkzeug/utils.py", line 408, in import_string
    return __import__(import_name)
    ImportStringError: import_string() failed for 'config'. Possible reasons are:
    - missing __init__.py in a package;
    - package or module path not included in sys.path;
    - duplicated package or module name taking precedence in sys.path;
    - missing module, class, function or variable;
    

What's wrong with my configuration?


Answer: import_string only takes absolute module imports. Since `config` is not a top-
level module, but part of `webapp`, you need to specify `webapp.config`. See
<http://flask.pocoo.org/docs/0.10/config/#configuring-from-files>:

    
    
    app = Flask(__name__)
    app.config.from_object('yourapplication.default_settings')
    app.config.from_envvar('YOURAPPLICATION_SETTINGS')
    

