Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Command Line Interface: bottle.ext ImportError #334

Closed
fredj opened this Issue Jun 13, 2012 · 3 comments

Comments

Projects
None yet
2 participants
Contributor

fredj commented Jun 13, 2012

To reproduce the issue:

Install a virtual environment:

$ virtualenv --no-site-packages venv
$ venv/bin/pip install bottle bottle-sqlalchemy sqlalchemy

Create a demo app, bottle.ext is imported but not used to simplify the test case:

$ cat > foobar.py << EOF
from bottle import Bottle, run
from bottle.ext import sqlalchemy

app = Bottle()

@app.get('/')
def hello():
    return "Hello world"

if __name__ == '__main__':
    run(app)

EOF

Run the app, it works:

$ venv/bin/python foobar.py
Bottle server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.

^CShutdown...

Use the Command Line Interface, ImportError:

$ venv/bin/bottle.py foobar:app
Shutdown...
Traceback (most recent call last):
  File "venv/bin/bottle.py", line 2929, in <module>
    run(args[0], host=host, port=port, server=opt.server, reloader=opt.reload, plugins=opt.plugin)
  File "venv/bin/bottle.py", line 2361, in run
    app = load_app(app)
  File "", line 2308, in load_app
    rv = load(target) # Import the target module
  File "venv/bin/bottle.py", line 2293, in load
    if module not in sys.modules: __import__(module)
  File "./foobar.py", line 2, in <module>
    from bottle.ext import sqlalchemy
ImportError: No module named ext

Same issue with the trunk version

Contributor

fredj commented Sep 19, 2012

To workaround this issue, from bottle.ext import sqlalchemy must be replaced with import bottle_sqlalchemy

Contributor

fredj commented Sep 19, 2012

works like a charm, thanks @iurisilvio

Owner

defnull commented Sep 19, 2012

Nice catch, nice patch. Thanks!

@defnull defnull closed this in c5381b6 Sep 19, 2012

@defnull defnull added a commit that referenced this issue Sep 20, 2012

@defnull defnull Merge pull request #380 from projectgus/master
Fix regression in pull request 378 (issue #334)
c97c84a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment