Flask-SQLAlchemy with Google App Engine only works in interactive console - python

I am trying to get my Google App Engine app to work with Flask-SQLAlchemy. I am getting the error:
AttributeError: 'module' object has no attribute 'paramstyle'
I have followed the instructions in this answer (Local MySQLdb connection fails with AttributeError for paramstyle when running GAE development server) and so I no longer get the error in the interactive console (when I make an app context).
However, the error still appears when I run the app in my local GAE. Why is this still happening? I am running OSX Mavericks. The full trace:
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 266, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/conor/Documents/Projj/lib/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/conor/Documents/Projj/financey.py", line 117, in login_view
userObj = get_user(username)
File "/Users/conor/Documents/Projj/financey.py", line 88, in get_user
return db.session.query(User).filter_by(username=username).first()
File "/Users/conor/Documents/Projj/lib/sqlalchemy/orm/scoping.py", line 149, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/Users/conor/Documents/Projj/lib/sqlalchemy/util/_collections.py", line 864, in __call__
return self.registry.setdefault(key, self.createfunc())
File "/Users/conor/Documents/Projj/lib/flask_sqlalchemy/__init__.py", line 139, in __init__
bind=db.engine,
File "/Users/conor/Documents/Projj/lib/flask_sqlalchemy/__init__.py", line 780, in engine
return self.get_engine(self.get_app())
File "/Users/conor/Documents/Projj/lib/flask_sqlalchemy/__init__.py", line 797, in get_engine
return connector.get_engine()
File "/Users/conor/Documents/Projj/lib/flask_sqlalchemy/__init__.py", line 473, in get_engine
self._engine = rv = sqlalchemy.create_engine(info, **options)
File "/Users/conor/Documents/Projj/lib/sqlalchemy/engine/__init__.py", line 332, in create_engine
return strategy.create(*args, **kwargs)
File "/Users/conor/Documents/Projj/lib/sqlalchemy/engine/strategies.py", line 69, in create
dialect = dialect_cls(**dialect_args)
File "/Users/conor/Documents/Projj/lib/sqlalchemy/dialects/mysql/base.py", line 1985, in __init__
default.DefaultDialect.__init__(self, **kwargs)
File "/Users/conor/Documents/Projj/lib/sqlalchemy/engine/default.py", line 124, in __init__
self.paramstyle = self.dbapi.paramstyle
AttributeError: 'module' object has no attribute 'paramstyle'
EDIT: In attempting to further diagnose the issue, when I import MySQLdb in the GAE Interactive Console (in the browser) I get the error ImportError: No module named _mysql

After looking around and debugging for far too long, I finally discovered the issue. When you run the GAE development server, the dev_appserver must be told exactly which MySQL instance you want to connect to. The connection string you use (e.g. in Python) doesn't matter. The connection string only determines database name and instance. However, SQLAlchemy can figure it out fine if you run form an ipython console. This may be due to a different driver being used under the hood.
Hopefully this saves someone else a lot of hair-pulling. Run your dev_appserver.py like so:
dev_appserver.py --mysql_host=<Cloud SQL IP> --mysql_user=root --mysql_password=<Cloud SQL root password> <application directory>

Related

How to solve 'no module named mysqldb'?

I am new to python. I am following a tutorial series tk make a website using flask. But when i fill up the contact form and then click on send i get this error
ModuleNotFoundError: No module named 'MySQLdb'
Traceback (most recent call last)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\util\_collections.py", line 1020, in __call__
return self.registry[key]
During handling of the above exception, another exception occurred:
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\acer\PycharmProjects\webdev.flask\first.1.py", line 46, in contact
db.session.add(entry)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\orm\scoping.py", line 163, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\util\_collections.py", line 1022, in __call__
return self.registry.setdefault(key, self.createfunc())
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\orm\session.py", line 3286, in __call__
return self.class_(**local_kw)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 138, in __init__
bind = options.pop('bind', None) or db.engine
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 943, in engine
return self.get_engine()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 962, in get_engine
return connector.get_engine()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 556, in get_engine
self._engine = rv = self._sa.create_engine(sa_url, options)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 972, in create_engine
return sqlalchemy.create_engine(sa_url, **engine_opts)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\engine\__init__.py", line 500, in create_engine
return strategy.create(*args, **kwargs)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\engine\strategies.py", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\dialects\mysql\mysqldb.py", line 118, in dbapi
return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
I tried to install mysqlient but it also gives ' cant build the wheel ' error.
I am using python 3.8
How to solve this issue?
if you use pycharm then file - > settings -> interpreter - > + (right). there you install wheel and mysql client (not always the latest version works)
if manually I assume that you are using a virtual environment, then you need to activate it and it already has "pip install wheel" also mysqlclient

psycopg2 error on Google App Engine

I'm hosting a website/app using Flask/SQLAlchemy on Google's App Engine, part of which entails communicating with a PostgreSQL server and querying it to populate the website. The SQL server is hosted on Google's Compute Engine as a VM instance per these instructions, but with the server open to all connections.
When I send a GET request to the website/app when it is hosted on localhost, I get the data I expect. However, when I launch the app and attempt to send the same request to the new URL, I get an HTTP 500 error. In GCP's logging section, I see the request and a stack trace containing the following:
(/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:279)
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 267, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/main.py", line 108, in get_book1
for item in models.Book.query.all():
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask_sqlalchemy/__init__.py", line 498, in __get__
return type.query_class(mapper, session=self.sa.session())
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/sqlalchemy/orm/scoping.py", line 78, in __call__
return self.registry()
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/sqlalchemy/util/_collections.py", line 990, in __call__
return self.registry.setdefault(key, self.createfunc())
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/sqlalchemy/orm/session.py", line 2829, in __call__
return self.class_(**local_kw)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask_sqlalchemy/__init__.py", line 145, in __init__
bind = options.pop('bind', None) or db.engine
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask_sqlalchemy/__init__.py", line 922, in engine
return self.get_engine()
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask_sqlalchemy/__init__.py", line 941, in get_engine
return connector.get_engine()
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/flask_sqlalchemy/__init__.py", line 543, in get_engine
self._engine = rv = sqlalchemy.create_engine(info, **options)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/sqlalchemy/engine/strategies.py", line 80, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/sqlalchemy/dialects/postgresql/psycopg2.py", line 554, in dbapi
import psycopg2
File "/base/data/home/apps/s~cs373-idb/20170411t063743.400476890985925133/lib/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dynamic module does not define init function (init_psycopg)
Given dummy data (i.e., having the app return some set data as opposed to querying the database,) the GET requests work fine, and TravisCI has no problem running tests which also involve querying the database using the same source, so I'm confident that the problem is with the database and its interaction with GAE.
I've read seemingly conflicting articles on Google's own website on whether or not PostgreSQL is supported by the App Engine. Is there a way to solve this?
If it helps, this is the lib folder that I've set for the app:
aniso8601 flask itsdangerous.py MarkupSafe-1.0.dist-info requests-2.13.0.dist-info SQLAlchemy-1.1.9.dist-info
aniso8601-1.2.0.dist-info Flask-0.12.1.dist-info itsdangerous.pyc psycopg2 requests_toolbelt werkzeug
click flask_restful jinja2 psycopg2-2.7.1.dist-info requests_toolbelt-0.7.1.dist-info Werkzeug-0.12.1.dist-info
click-6.7.dist-info Flask_RESTful-0.3.5.dist-info Jinja2-2.9.6.dist-info python_dateutil-2.6.0.dist-info six-1.10.0.dist-info
coverage flask_sqlalchemy markup pytz six.py
coverage-4.3.4.dist-info Flask_SQLAlchemy-2.2.dist-info markup-0.2.dist-info pytz-2017.2.dist-info six.pyc
dateutil itsdangerous-0.24.dist-info markupsafe requests sqlalchemy
These libraries were added from GCP's console with the command:
pip install -r requirements.txt -t lib
where requirements.txt contains this list:
Flask
Flask-SQLAlchemy
psycopg2
Markup
requests
flask_restful
requests-toolbelt
coverage
Finally, my python version is 2.7.9 and pip 9.0.1
Thank you in advance for taking the time to read this. Any advice would be immensely appreciated.

Flask-Dance Error: Scope has changed

I am using flask-dance to authenticate to Google's servers.
Config for flask-dance:
from flask.ext.dance.contrib.google import make_google_blueprint
google_blueprint = make_google_blueprint (
client_id=app.config['GOOGLE']['client_id'],
client_secret=app.config['GOOGLE']['client_secret'],
scope=["profile", "email"],
redirect_to="main.index",
login_url="/",
authorized_url="/authorized",
)
app.register_blueprint(google_blueprint,url_prefix="/login")
However, I am getting Warning: Scope has changed from "profile email" to "". after you go through Google's credential dialog box.
Here's the full trace:
Traceback (most recent call last):
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/flask_dance/consumer/oauth2.py", line 168, in authorized
client_secret=self.client_secret,
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/requests_oauthlib/oauth2_session.py", line 199, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 409, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 376, in parse_token_response
validate_token_parameters(params)
File "/home/xxx/.virtualenvs/flask/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 406, in validate_token_parameters
raise w
Warning: Scope has changed from "profile email" to "".
On the Chrome Dev Console I get this (after the Account Chooser window right before the traceback):
GET http://localhost:5000/login/authorized?state=11rtXcAHJm0jloiDpM8IrazD9uLT3b…xnXM0ZB1DumOPqFOgu-x19CDSbDfQoKLWVEfBRTQIg.gvDk1rm330AV3oEBd8DOtNAR0Vr7lQI 500 (INTERNAL SERVER ERROR)
Navigated to http://localhost:5000/login/authorized?state=11rtXcAHJm0jloiDpM8IrazD9uLT3b…xnXM0ZB1DumOPqFOgu-x19CDSbDfQoKLWVEfBRTQIg.gvDk1rm330AV3oEBd8DOtNAR0Vr7lQI
If I do os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] = '1' it works, but I don't think this is a solution but more of a workaround for now. :(
I opened a ticket on the issue Google OAuth2 returns no scope on authentication breaks scope test #306 on the issue.
From what I can tell from https://www.rfc-editor.org/rfc/rfc6749#section-3.3, Google isn't required to return the scope (unless the scope was changed), am I reading this correctly?
Nearest thing I can figure is there is a bug in the oauthlib plugin which I opened a bug report with already.
From the bug report, you can fix the issue by changing the file /oauth2/rfc6749/tokens.py in the plugin on Line 30 from self._new_scope = set(utils.scope_to_list(params.get('scope', ''))) to self._new_scope = set(utils.scope_to_list(params.get('scope', old_scope)))
Fix was merged: https://github.com/idan/oauthlib/pull/323

User-Restricted Resource Access

I'm trying to enable "User-Restricted Resource Access" in my eve application with Basic Authentication. http://python-eve.org/authentication.html#user-restricted-resource-access
The Problem is since I enabled it I get for every http request on the API a "500 error"
If I fire up the API without basic authentication params I get a bad credentials error, so the Basic Authentication works fine.
This is the eve DEBUG Output:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python2.7/dist-packages/Eve-0.3-py2.7.egg/eve/methods/common.py", line 226, in rate_limited
return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Eve-0.3-py2.7.egg/eve/auth.py", line 43, in decorated
if not auth.authorized(roles, resource_name, request.method):
File "/usr/local/lib/python2.7/dist-packages/Eve-0.3-py2.7.egg/eve/auth.py", line 97, in authorized
allowed_roles, resource, method)
**File "/home/maanuel/emberv/eve/run.py", line 12, in check_auth
self.set_request_auth_value(account['_id'])
AttributeError: 'BCryptAuth' object has no attribute 'set_request_auth_value'**
It seems like the set_request_auth_class is missing
I'm using eve 0.3 installed with easy_install
You are reading the documentation about the development version (as stated on all pages at python-eve.org.) One relevant change coming with v0.4 is the way auth tokens are set. So basically, you are applying 0.4-dev syntax to Eve v0.3. You should probably follow these instructions instead.
PS: 0.4 is due for release real soon so you might want to stick with that one, so you don't have to update your code again soon.

Pyimgur code works on Windows, not on Ubuntu

I have a simple code that creates an album in imgur, via pyimgur. This is the code:
#app.route('/get_album')
def get_album():
im = pyimgur.Imgur(CLIENT_ID)
new_album = im.create_album()
return new_album.link
(I tried with im = pyimgur.Imgur(CLIENT_ID) line before the route handlers as well, same thing happens)
On Windows, everything is perfectly fine. However, when I upload the code to my VPS, I get the following error when I try to do something with the api:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __ca ll__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi _app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in hand le_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi _app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full _dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in hand le_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full _dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in disp atch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/api/imgur.py", line 161, in get_album_link
new_album = im.create_album()
File "/usr/local/lib/python2.7/dist-packages/pyimgur-0.4.2-py2.7.egg/pyimgur/_ _init__.py", line 754, in create_album
resp = self._send_request(url, params=payload, method='POST')
File "/usr/local/lib/python2.7/dist-packages/pyimgur-0.4.2-py2.7.egg/pyimgur/_ _init__.py", line 687, in _send_request
result = request.send_request(url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyimgur-0.4.2-py2.7.egg/pyimgur/r equest.py", line 91, in send_request
content = resp.json()
TypeError: 'dict' object is not callable
I updated flask to the latest version, and I've been using pyimgur 4, latest release I got from github (pip install doesnt work so I had to install it manually, on both Windows and Ubuntu, since some error about setup.py pops out. I used python setup.py install command)
OK, so I have found a solution. The solution was a change in requests module, which probably came along with updated flask or something, so the old method didn't behave like it used to. I updated the requests as well on my VPS (forgot to do it when upgrading flask), and the issue is now solved.

Categories

Resources