weird django error: cannot import name get_path_info - django

I suddenly started getting this error when I try to start the django development server, and I cannot figure out where it is coming from. I have tried updating django.
File "/virtualEnv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 6, in <module>
from django.contrib.staticfiles.handlers import StaticFilesHandler
File "/virtualEnv/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 9, in <module>
from django.core.handlers.base import get_path_info
ImportError: cannot import name get_path_info
Has anyone seen any error like this before? Definitely trying my best to figure this out...

For me, the problem was that dj_static 0.0.5 didn't seem to be playing nicely with Django 1.7. I upgraded to dj_static 0.0.6 and it fixed it.

I had a similar issue.
Resolved for Django 1.7 by changing the import path for get_path_info:
from django.core.handlers.base import get_path_info
became:
from django.core.handlers.wsgi import get_path_info

Related

Getting error while running "superset re-encrypt-secrets" in superset

from superset.app import create_app
File "C:\Users\delli\AppData\Local\Programs\Python\Python39\lib\site-packages\superset\app.py", line 29, in <module>
from superset.extensions import (
ImportError: cannot import name 'jinja_context_manager' from 'superset.extensions' (C:\Users\delli\AppData\Local\Programs\Python\Python39\lib\site-packages\superset\extensions\__init__.py)
I am using Flask verion 2.1.0.
Updated the secret key in superset_config.py and tried to run "superset re-encrypt-secrets" command. Then getting import error for 'jinja_context_manager'.
I have tried downgrade the version of flask and pandas. But did not get resolved.

flask_bcrypt, werkzeug.security.safe_str_cmp fails after upgrade to latest flask 2.1

I've upgraded my project to latest flask (2.1.2 and now I'm getting following error:
Traceback (most recent call last):
File "/home/ff/conveyors/run.py", line 1, in <module>
from conveyors import create_app
File "/home/ff/conveyors/conveyors/__init__.py", line 4, in <module>
from flask_bcrypt import Bcrypt
File "/home/ff/.cache/pypoetry/virtualenvs/conveyors-SV5d9Vx2-py3.9/lib/python3.9/site-packages/flask_bcrypt.py", line 21, in <module>
from werkzeug.security import safe_str_cmp
ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security'
In my __init__.py I have
...
from flask_bcrypt import bcrypt
from flask_login import LoginManager
...
and then below in create_app:
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(Config)
db.init_app(app)
bcrypt.init_app(app)
login_manager.init_app(app)
...
I've read Werkzeug release note about safe_str_cmp being removed from Werkzeug 2.1 and needs to be replaced with equivalent hmac functions, but I'm not sure what I need to do in my code to fix this.
Any help greatly appreciated.
Thanks.
It turned out to be a poetry update problem. Whatever I tried it wouldn't upgrade flask_bcrypt to the latest version 1.0.1 and stayed with 0.7.1
I had to start kind of from scratch and do
poetry add flask
...
for every package needed for this app

ImportError: cannot import name routes

I am doing Miguel Grinberg's tutorial on Flask. I am having a strange issue: before, this wasn't happening, but now it is. When I try to run flask shell or simply run my application, I receive the following error:
NoAppException: While importing "app.microblog", an ImportError was raised:
Traceback (most recent call last):
File "c:\projects\blog\virtualenv\lib\site-packages\flask\cli.py", line 235, in locate_app
__import__(module_name)
File "c:\Projects\Blog\app\__init__.py", line 14, in <module>
from app import routes, models
File "app.py", line 11, in <module>
ImportError: cannot import name routes
I thought it might be a circular dependency problem, but that didn't seem to be the case. I've tried searching all over for the answre but can't seem to figure it out.
Thanks for your help.
It seems you are importing the routes from app module within app module.. If you can share some more snippet, that would be helpful in understanding the problem.
But it seems,
from app import routes, models
File "app.py", line 11, in <module>
ImportError: cannot import name routes
In these lines, it says the exception is occuring in from app import routes, models line which is line 11 of app.py file.
So you are just importing the app module within app module.
I think you shouldn't import like the way you do already. Instead use the following:
import app
...
...
...
#app.routes('/something', methods=['DESIRED_METHODS']
def your_function():
pass

Django-inline-media get_model error

I am using Django 1.9 and for my project I need django-inline-media. I have done all stuff properly as per documentation. But I get this error.
File "/home/sifat/PycharmProjects/fear/profiles/models.py", line 3, in <module>
from inline_media.fields import TextFieldWithInlines
File "/home/sifat/PycharmProjects/fear/env/local/lib/python2.7/site- packages/inline_media/fields.py", line 4, in <module>
from django.db.models import fields, get_model
ImportError: cannot import name get_model
Now what to do? As it is error from a library
django.db.models.get_model has been deprecated in Django 1.7 and was removed in 1.9.
In Django 1.9, you can replace it with
from django.apps import apps
model = apps.get_model('app_name', 'model_name')

ImportError : cannot import name AppCache

I have installed Django 1.8.3 Then i created my project. I need to import the AppCache but not able to import it. In Django shell i wrote
from django.db.models.loading import AppCache
Error is:
ImportError: cannot import name AppCache
Please help me out.
AppCache is not a part of django.db.models.loading from django 1.7 onwards.For more information you can read this link