2016-06-28 13 views
9

Kiedy uruchomić mój skrypt, otrzymuję ten wynik:Jak mogę wyłączyć ExtDeprecationWarning dla bibliotekami zewnętrznymi w kolbie

/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.sqlalchemy is deprecated, use flask_sqlalchemy instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.marshmallow is deprecated, use flask_marshmallow instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.cache is deprecated, use flask_cache instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.restful is deprecated, use flask_restful instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.restful.fields is deprecated, use flask_restful.fields instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.restful.reqparse is deprecated, use flask_restful.reqparse instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.restplus is deprecated, use flask_restplus instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.restful.representations is deprecated, use flask_restful.representations instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.script is deprecated, use flask_script instead. 
    .format(x=modname), ExtDeprecationWarning 
/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.migrate is deprecated, use flask_migrate instead. 
    .format(x=modname), ExtDeprecationWarning 

nie troszczą się o to, bo libs zewnętrzne są tego przyczyną. Nie mogę zaktualizować tych bibliotek, ponieważ ich nie posiadam i widzę, że dla kilku oczekujących żądań oczekujących.

Jak mogę uzyskać spokój i ciszę?

Odpowiedz

13

As of Flask 1.0, flask.ext nie istnieje. Pakiety, które nie naprawiły tego importu, nie będą działać.


pierwsze, powinien troska o to, ponieważ pakiety których używasz nie są aktualne. Zgłaszanie błędu, który powinien zmienić przy użyciu bezpośrednich nazw importu, takich jak flask_sqlalchemy, zamiast haka importu flask.ext.

Dodaj linię warnings.simplefilter, aby odfiltrować te ostrzeżenia. Możesz umieścić go w dowolnym miejscu, w którym konfigurujesz swoją aplikację, przed wykonaniem importu, który spowodowałby wygenerowanie ostrzeżenia.

import warnings 
from flask.exthook import ExtDeprecationWarning 

warnings.simplefilter('ignore', ExtDeprecationWarning) 
0

Nie mogę zdecydować na pewno z twojego pytania, ale jestem prawie pewien, że to import w twoich plikach źródłowych powoduje ostrzeżenia.

Jeśli używasz przestarzałej import flask.ext przekierowanie, to na przykład:

flask.ext.sqlalchemy import SQLAlchemy() 

staje bezpośredni import:

from flask_sqlalchemy import SQLAlchemy() 

Jeśli używasz Linuksa, to jedno-liner spowoduje zmianę rekurencyjnie wszystkich plików i folderów (z ./).

Najpierw wykonaj kopię zapasową innej ścieżki pliku - nie mogę z całą pewnością stwierdzić, że nie uszkodzi ona zawartości katalogu .git lub innego używanego pliku svn itp. Lub po prostu wprowadź poprawki ręcznie.

find ./ -type f exec sed -i 's/flask.ext./flask_/g' {} \; 
+0

Twoje założenie jest błędne, co zostało wyraźnie wskazane w pytaniu i widziane w dzienniku błędów. – jwg

Powiązane problemy