I understand that Pandas isn't included and believe that I've properly included the library via adding the module into the lib directory for the app and by adding
from google.appengine.ext import vendor
vendor.add('lib')
to appengine_config.py - other modules don't seem to be having issues.
When I run my app, the following stack trace shows up:
ERROR 2016-12-15 23:05:31,038 app.py:1587] Exception on / [GET]
Traceback (most recent call last):
File ".../PycharmProjects/fpl-flask-app/lib/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File ".../PycharmProjects/fpl-flask-app/lib/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File ".../PycharmProjects/fpl-flask-app/lib/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File ".../PycharmProjects/fpl-flask-app/lib/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File ".../PycharmProjects/fpl-flask-app/lib/flask/app.py", line 1625, in dispatch_request
return self.view_functionsrule.endpoint
File ".../PycharmProjects/fpl-flask-app/main.py", line 13, in index
datar = pandas.read_sql('SELECT p.nationality, SUM(s.mins_played) AS mins_played
FROM CurrentSeasonStats s left join Player p ON s.Player_pid = p.pid GROUP BY
p.nationality', con)
AttributeError: 'module' object has no attribute 'read_sql'**
Here's my code:
from flask import Flask, request, render_template
import pandas
from sqlalchemy import create_engine
import pymysql
import random
app = Flask(__name__)
@app.route('/')
def index():
con = create_engine('mysql+pymysql://user:[email protected]:port/fpl', echo=False)
datar = pandas.read_sql('SELECT p.nationality, SUM(s.mins_played) AS mins_played FROM CurrentSeasonStats s left join Player p ON s.Player_pid = p.pid GROUP BY p.nationality', con)
return render_template('index.html', table=datar)
if __name__ == '__main__':
app.run()
Any ideas?
I had copy-pasted a Binary Skeleton version of the pandas library into /lib/ which is why none of the pandas functions were working.
This a direct and annoying result of me not using virtual environments...
USE VIRTUAL ENVIRONMENTS, KIDS!