After installing the Flask-Migrate package I am not able to run the command flask db init it says that it is not recognized. I was using this before with no issue now it has stopped working.
usage: flask [-h] [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver]
[--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
[--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
flask: error: unrecognized arguments: db init
Name: Flask-Migrate
Version: 2.1.1
Summary: SQLAlchemy database migrations for Flask applications using Alembic
Home-page: http://github.com/miguelgrinberg/flask-migrate/
Author: Miguel Grinberg
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python2.7/dist-packages
Requires: alembic, Flask, Flask-SQLAlchemy
Something is strange in your virtual environment. The output of the flask command is not what it should be. I suggest you recreate your environment from scratch.
So I am not using it in a virtual environment like virtualvenv. It is inside a docker container that would be running my application. Would that be making a difference?
No, that should be the same. Do you have any scripts in your application that are called flask maybe? Something that could be shadowing the real flask command?
No the weird part was it was working fine two weeks ago. I was able able to init the dB and was able to migrate it. I went to use it again a week ago and the flask command wasn鈥檛 working. In the application it doesn鈥檛 use the flask cli nor does th docket file when making the container.
what do you get when you run which flask in the context of the container? Run that, then take a look at the file that is reported to see what's inside.
When running the command I got this as a response.
/usr/local/bin/flask
In case your problem is still there:
I ran into the same issue. It was due to configparser used in my application.
The error message coma from my application and not flask itself.
Replacing
args = parser.parse_args()
with
args, _ = parser.parse_known_args()
resolves the issue since configparser will then ignore unknow arguments.
In case your problem is still there:
I ran into the same issue. It was due to configparser used in my application that was also trying to parse the command line argument of the 'flaks db migrate' command.
The error message came in fact from my application and not flask itself.
Replacing
args = parser.parse_args()
with
args, _ = parser.parse_known_args()
resolves the issue since configparser will then ignore unknow arguments.
In case your problem is still there:
I ran into the same issue. It was due to configparser used in my application that was also trying to parse the command line argument of the 'flaks db migrate' command.
The error message came in fact from my application and not flask itself.
Replacing
args = parser.parse_args()
with
args, _ = parser.parse_known_args()
resolves the issue since configparser will then ignore unknow arguments.
This worked for me. Thank you, kind sir.
Most helpful comment
In case your problem is still there:
I ran into the same issue. It was due to configparser used in my application that was also trying to parse the command line argument of the 'flaks db migrate' command.
The error message came in fact from my application and not flask itself.
Replacing
args = parser.parse_args()with
args, _ = parser.parse_known_args()resolves the issue since configparser will then ignore unknow arguments.