0

I'm following the flask mega tutorial, I'm currently trying to run the "flask db migrate" command but I get some errors and I'm not sure if I'm to stupid to see it but its not referring to any of my files really.

Traceback (most recent call last):
  File "/home/moe/cryptowatch/venv/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask/cli.py", line 967, in main
    cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask/cli.py", line 426, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_migrate/cli.py", line 91, in migrate
    _migrate(directory, message, sql, head, splice, branch_label, version_path,
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_migrate/__init__.py", line 96, in wrapped
    f(*args, **kwargs)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_migrate/__init__.py", line 210, in migrate
    command.revision(config, message, autogenerate=True, sql=sql,
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/alembic/command.py", line 212, in revision
    script_directory.run_env()
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/alembic/script/base.py", line 490, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/alembic/util/pyfiles.py", line 97, in load_python_file
    module = load_module_py(module_id, path)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/alembic/util/compat.py", line 182, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "migrations/env.py", line 25, in <module>
    str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%'))
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 943, in engine
    return self.get_engine()
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 962, in get_engine
    return connector.get_engine()
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 555, in get_engine
    options = self.get_options(sa_url, echo)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 570, in get_options
    self._sa.apply_driver_hacks(self._app, sa_url, options)
  File "/home/moe/cryptowatch/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 914, in apply_driver_hacks
    sa_url.database = os.path.join(app.root_path, sa_url.database)
AttributeError: can't set attribute
L1ne
  • 1

1 Answers1

-1

See this thread for more info. If you have version 1.4.0 of sqlalchemy uninstall it and install the previous version.

If your code is correct then that should solve the problem.

Ange Uwase
  • 561
  • 4
  • 10