Forums

Trouble installing Flask application

First time user of PythonAnywhere. Ops is not my wheelhouse so keep that in mind. Also, the getting started walkthrough isn't super helpful. I had to google to find out how to get code into my account.

  • I've got my free account ready for testing.
  • I cd into the mysite folder.
  • I've git cloned my repository
  • I run pip install - requirements.txt and everything goes well, until the end when I get the following output:

-

Downloading/unpacking Flask==0.10.1 (from -r requirements.txt (line 1))
  Downloading Flask-0.10.1.tar.gz (544kB): 544kB downloaded
  Running setup.py (path:/tmp/pip_build_commadelimited/Flask/setup.py) egg_info for package Flask

    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'examples'
    warning: no previously-included files matching '*.pyo' found under directory 'examples'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes/.git'
Downloading/unpacking Flask-Login==0.2.11 (from -r requirements.txt (line 2))
  Downloading Flask-Login-0.2.11.tar.gz
  Running setup.py (path:/tmp/pip_build_commadelimited/Flask-Login/setup.py) egg_info for package Flask-Login

Downloading/unpacking Flask-WTF==0.10.2 (from -r requirements.txt (line 3))
  Downloading Flask_WTF-0.10.2-py2.py3-none-any.whl
Downloading/unpacking Jinja2==2.7.3 (from -r requirements.txt (line 4))
  Downloading Jinja2-2.7.3.tar.gz (378kB): 378kB downloaded
  Running setup.py (path:/tmp/pip_build_commadelimited/Jinja2/setup.py) egg_info for package Jinja2

    warning: no files found matching '*' under directory 'custom_fixers'
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
Downloading/unpacking MarkupSafe==0.23 (from -r requirements.txt (line 5))
  Downloading MarkupSafe-0.23.tar.gz
  Running setup.py (path:/tmp/pip_build_commadelimited/MarkupSafe/setup.py) egg_info for package MarkupSafe

Downloading/unpacking Unidecode==0.04.16 (from -r requirements.txt (line 6))
  Downloading Unidecode-0.04.16.tar.gz (200kB): 200kB downloaded
  Running setup.py (path:/tmp/pip_build_commadelimited/Unidecode/setup.py) egg_info for package Unidecode

Downloading/unpacking WTForms==2.0.1 (from -r requirements.txt (line 7))
  Downloading WTForms-2.0.1.zip (444kB): 444kB downloaded
  Running setup.py (path:/tmp/pip_build_commadelimited/WTForms/setup.py) egg_info for package WTForms

    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
Downloading/unpacking Werkzeug==0.9.6 (from -r requirements.txt (line 8))
  Downloading Werkzeug-0.9.6.tar.gz (1.1MB): 1.1MB downloaded
  Running setup.py (path:/tmp/pip_build_commadelimited/Werkzeug/setup.py) egg_info for package Werkzeug

    warning: no files found matching '*' under directory 'werkzeug/debug/templates'
    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'examples'
    warning: no previously-included files matching '*.pyo' found under directory 'examples'
    no previously-included directories found matching 'docs/_build'
Downloading/unpacking awesome-slugify==1.6 (from -r requirements.txt (line 9))
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1197, in prepare_files
    do_download,
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1375, in unpack_url
    self.session,
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 546, in unpack_http_url
    resp = session.get(target_url, stream=True)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 468, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 237, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/adapters.py", line 378, in send
    raise ProxyError(e)
ProxyError: ('Cannot connect to proxy.', error(111, 'Connection refused'))

Storing debug log for failure in /home/commadelimited/.pip/pip.log

Here's the contents of my requirements.txt file.

Flask==0.10.1
Flask-Login==0.2.11
Flask-WTF==0.10.2
Jinja2==2.7.3
MarkupSafe==0.23
Unidecode==0.04.16
WTForms==2.0.1
Werkzeug==0.9.6
awesome-slugify==1.6
blinker==1.3
gnureadline==6.3.3
gunicorn==19.1.1
ipdb==0.8
ipython==2.3.0
itsdangerous==0.24
peewee==2.4.0
py-bcrypt==0.4
pytz==2014.7
regex==2014.10.24
wsgiref==0.1.2
wtf-peewee==0.2.3

Is there something I'm missing? Am I skipping a step, or doing something wrong? I'm pretty sure my process is legit because there's only 2 steps: clone the app, install requirements. But anyway, I'd love some feedback that would help me determine what's going wrong.

[edit by admin: formatting]

By the way, here's the error.log from my account:

2014-11-08 15:40:44,230 :Traceback (most recent call last):
2014-11-08 15:40:44,262 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2014-11-08 15:40:44,263 :    self.error_log_file.logger.exception("Error running WSGI application")
2014-11-08 15:40:44,263 :  File "/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2014-11-08 15:40:44,264 :    self.error(msg, *args, **kwargs)
2014-11-08 15:40:44,264 :  File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2014-11-08 15:40:44,264 :    self._log(ERROR, msg, args, **kwargs)
2014-11-08 15:40:44,264 :  File "/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2014-11-08 15:40:44,265 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2014-11-08 15:40:44,265 :  File "/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2014-11-08 15:40:44,266 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2014-11-08 15:40:44,266 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2014-11-08 15:40:44,266 :    self.threadName = threading.current_thread().name
2014-11-08 15:40:44,266 :  File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
2014-11-08 15:40:44,267 :    return _active[_get_ident()]
2014-11-08 15:40:44,268 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2014-11-08 15:40:44,268 :    app_iterator = self.app(environ, start_response)
2014-11-08 15:40:44,268 :  File "/bin/user_wsgi_wrapper.py", line 136, in import_error_application
2014-11-08 15:40:44,268 :    raise e
2014-11-08 15:40:44,268 :ImportError: No module named flask_app

Also, there's nothing in my code referencing flask_app.

OK, there are a couple of things that should help. You need to use the --user flag when installing your requirements on PythonAnywhere, ie.

pip install --user -r requirements.txt

The other thing is that once they're installed, you'll need to modify your WSGI file (linked from the "Web" tab to put the path where you installed your app onto sys.path and to import the appropriate name from your main module.

Give that a go and post back here if it still doesn't work.

One other thing: someone just sent us a link to a bug in pip that seems to happen with large requirements files and proxies (which impacts our free accounts). I think it might help to split your requirements file into a number of smaller ones and install them separately if you still get the 111 error when you use the --user flag.

Are you runnung pip from a virtualenv?

if not try the --user option to pip to install the dependencies to your home directory.

edit: just noticed, the duplication "Save button is the ultimate proofreading tool ;-)"

OK, we've discovered a workaround for this: run this in a bash console:

pip2.7 install --user -U pip==1.4

This will downgrade pip for your account to a version without the proxy bug.

Very useful to me.