pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.8k stars 1.58k forks source link

Flask-admin cannot import name _class_resolver, under uWSGI and Nginx #1559

Open jonalxh opened 7 years ago

jonalxh commented 7 years ago

I've hosted a python Flask project in AWS using uWSGI and Nginx, initially everything worked fine, but then I decided to implement Flask-admin module. Now page is showing me an Internal Server Error message.

I've checked UWSGI log and says:

  Traceback (most recent call last):
  File "/var/www/project/run.py", line 2, in <module>
    from app import app
  File "/var/www/project/app/__init__.py", line 22, in <module>
    from app import views
  File "/var/www/project/app/views.py", line 15, in <module>
    from flask_admin.contrib.sqla import ModelView
  File "/var/www/project/venv/local/lib/python2.7/site-packages/flask_admin/contrib/sqla/__init__.py", line 2, in <module>
    from .view import ModelView
  File "/var/www/project/venv/local/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 17, in <module>
    from flask_admin.contrib.sqla.tools import is_relationship
  File "/var/www/project/venv/local/lib/python2.7/site-packages/flask_admin/contrib/sqla/tools.py", line 4, in <module>
    from sqlalchemy.ext.declarative.clsregistry import _class_resolver
ImportError: cannot import name _class_resolver
Fri Nov 10 07:41:08 2017 - unable to load app 0 (mountpoint='project.domain.com|') (callable not found or import error)
Fri Nov 10 07:41:08 2017 - --- no python application found, check your startup logs for errors ---

My app/views.py imports are:

# -*- coding: utf-8 -*-
import os, time
from app import app
import flask
from flask import render_template, request, jsonify, send_from_directory, send_file, session, redirect, g, url_for, make_response, session, request
from flask_sqlalchemy import SQLAlchemy
from models import RequestsLog
import requests
import json
from app import db, appname
import flask_admin as admin
from flask_admin import Admin, helpers, expose
from flask_admin.contrib.sqla import ModelView
from flask_admin.contrib import sqla

I've posted this question in stack overflow with more details: https://stackoverflow.com/questions/47223592/flask-admin-cannot-import-name-class-resolver-under-uwsgi-and-nginx

Thanks a lot for your help.

n1ngu commented 2 years ago

Fixed 2 years ago in v1.5.7, see #2033