I am trying to set up alembic to check my db, but I am getting this error when I try to run the command mentioned below.
Folder architecture:
Part of the configuration (env.py) The error is on import
from logging.config import fileConfig
from sqlalchemy import engine_from_config, pool
from src.infra.sqlalchemy.config.database import Base #The error is here
from src.infra.sqlalchemy.models.models import * #The error is here
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata
Command executed in terminal (bash)
$ alembic revision --autogenerate -m "inicial"
Log error:
Traceback (most recent call last):
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\Scripts\alembic.exe\__main__.py", line 7, in <module>
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\config.py", line 590, in main
CommandLine(prog=prog).main(argv=argv)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\config.py", line 584, in main
self.run_cmd(cfg, options)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\config.py", line 561, in run_cmd
fn(
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\command.py", line 229, in revision
script_directory.run_env()
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\script\base.py", line 569, in run_env
util.load_python_file(self.dir, "env.py")
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\util\pyfiles.py", line 94, in load_python_file
module = load_module_py(module_id, path)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\util\pyfiles.py", line 110, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "alembic\env.py", line 5, in <module>
from src.infra.sqlalchemy.models.models import *
File "C:\backEnd_py\app_blx\app_blx\.\src\infra\sqlalchemy\models\models.py", line 1, in <module>
from infra.sqlalchemy.config.database import Base
ModuleNotFoundError: No module named 'infra'
Related
I am developing a code where I need to create a Manager to synchronize a Queue. In the project I am using hydra and everything works fine until I create a multiprocessing Manager Object. This is the raised error with HYDRA_FULL_ERROR=1:
Primary config module 'config' not found.
Check that it's correct and contains an __init__.py file
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
Traceback (most recent call last):
File "mre.py", line 8, in <module>
main()
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\main.py", line 32, in decorated_main
_run_hydra(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\utils.py", line 355, in _run_hydra
run_and_report(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\utils.py", line 207, in run_and_report
return func()
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\utils.py", line 356, in <lambda>
lambda: hydra.run(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\hydra.py", line 107, in run
return run_job(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\core\utils.py", line 125, in run_job
ret.return_value = task_function(task_cfg)
File "mre.py", line 7, in main
m = Manager()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\context.py", line 57, in Manager
m.start()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\managers.py", line 583, in start
self._address = reader.recv()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\connection.py", line 250, in recv
buf = self._recv_bytes()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\connection.py", line 305, in _recv_bytes
waitres = _winapi.WaitForMultipleObjects(
KeyboardInterrupt
^C
C:\Users\UX331U\Desktop>SET HYDRA_FULL_ERROR=1
C:\Users\UX331U\Desktop>python mre.py
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\UX331U\Desktop\mre.py", line 8, in <module>
main()
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\main.py", line 32, in decorated_main
_run_hydra(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\utils.py", line 355, in _run_hydra
run_and_report(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\utils.py", line 210, in run_and_report
raise ex
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\utils.py", line 207, in run_and_report
return func()
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\utils.py", line 356, in <lambda>
lambda: hydra.run(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\hydra.py", line 100, in run
cfg = self.compose_config(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\hydra.py", line 505, in compose_config
self.config_loader.ensure_main_config_source_available()
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\config_loader_impl.py", line 135, in ensure_main_config_source_available
self.missing_config_error(
File "C:\Users\UX331U\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hydra\_internal\config_loader_impl.py", line 109, in missing_config_error
raise MissingConfigException(
hydra.errors.MissingConfigException: Primary config module 'config' not found.
Check that it's correct and contains an __init__.py file
I also attach a minimal code snippet to reproduce the error.
import hydra
from multiprocessing import Manager
#hydra.main(config_path='config', config_name='config')
def main(cfg):
m = Manager() # The error is in this line
m.Queue()
main()
The config.yaml is correctly created and located since when I don't use the Manager, the entire code works with no errors:
- PROJECT ----- config ---- config.yaml
|
|
----- main.py
As far as I have understood, the problem comes from the fact that hydra changes the directory when initialized and afterwards, when the Manager is created, hydra is called again to be initialized but as the directory has been changed, it can not find the config folder. If this is true, is it a bug or can it be solved?
Thank you so much for your help.
I'm not able to reproduce the error on my machine.
You can stop hydra from changing directories at runtime by passing hydra.job.chdir=False at the command line -- see the docs on how to disable changing current working dir to job's output dir.
python main.py hydra.job.chdir=False
I'm getting this error after running the following command:
C:\Users\callu\project_name>celery -A project_name worker -l info
I'm wondering if it has something to do with the fact that I've not created my django project in a virtual environment but I can't find anything on the issue. If it was due to it being outside a virtual environment I'm not sure how I'd get around it without restarting the project in one (is it easy to move to a venv in PyCharm?)
I run my django server and my above celery command here:
C:\Users\callu\project_name>
I run start my RabbitMQ server in another location (not venv) but don't think that's the issue
Full Traceback:
Traceback (most recent call last):
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\cached_property.py", line 70, in __get__
return obj_dict[name]
KeyError: 'data'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\callu\AppData\Local\Programs\Python\Python37-32\Scripts\celery.exe\__main__.py", line 7, in <module>
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\__main__.py", line 15, in main
sys.exit(_main())
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\bin\celery.py", line 213, in main
return celery(auto_envvar_prefix="CELERY")
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1135, in invoke
sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 641, in make_context
self.parse_args(ctx, args)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 940, in parse_args
value, args = param.handle_parse_result(ctx, opts, args)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1477, in handle_parse_result
self.callback, ctx, self, value)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 96, in invoke_param_callback
return callback(ctx, param, value)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\bin\worker.py", line 156, in <lambda>
value: value or ctx.obj.app.conf.worker_state_db,
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 111, in __getattr__
return self[k]
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 391, in __getitem__
return getitem(k)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 249, in __getitem__
return mapping[_key]
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\collections\__init__.py", line 1021, in __getitem__
if key in self.data:
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\kombu\utils\objects.py", line 29, in __get__
return super().__get__(instance, owner)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\cached_property.py", line 74, in __get__
return obj_dict.setdefault(name, self.func(obj))
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 138, in data
return self.callback()
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 946, in _finalize_pending_conf
conf = self._conf = self._load_config()
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 956, in _load_config
self.loader.config_from_object(self._config_source)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 123, in config_from_object
obj = self._smart_import(obj, imp=self.import_from_cwd)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 136, in _smart_import
return symbol_by_name(path, imp=imp)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\kombu\utils\imports.py", line 56, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 95, in import_from_cwd
package=package,
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\imports.py", line 100, in import_from_cwd
return imp(module, package=package)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 89, in import_module
return importlib.import_module(module, package=package)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django.config'
It sounds like you have somewhere (in your app/celery.py if using the standard layout) a line that looks like:
app.config_from_object('django.config:settings', namespace='CELERY')
where app is your Celery app object.
But what you need is:
app.config_from_object('django.conf:settings', namespace='CELERY')
Note: you the django config module is django.conf not django.config.
In spacy 3.0 I have registered my custom Language like this:
import spacy
from spacy.lang.en import English
class CustomEnglishDefaults(English.Defaults):
stop_words = set(["custom", "stop"])
#spacy.registry.languages("custom_en")
class CustomEnglish(English):
lang = "custom_en"
Defaults = CustomEnglishDefaults
I've tried the code line nlp = spacy.blank("custom_en") and it works fine.
But when I use lang="custom-en" in a config.cfg file and use the command :
python -m spacy train config.cfg --paths.train ./train.spacy --paths.dev ./dev.spacy
I get the following error:
Traceback (most recent call last):
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/util.py", line 244, in get_lang_class
module = importlib.import_module(f".lang.{lang}", "spacy")
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'spacy.lang.custom_en'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/__main__.py", line 4, in <module>
setup_cli()
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/cli/_util.py", line 69, in setup_cli
command(prog_name=COMMAND)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/typer/main.py", line 497, in wrapper
return callback(**use_params) # type: ignore
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/cli/train.py", line 56, in train_cli
nlp = init_nlp(config, use_gpu=use_gpu)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/training/initialize.py", line 39, in init_nlp
nlp = load_model_from_config(raw_config, auto_fill=True)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/util.py", line 425, in load_model_from_config
lang_cls = get_lang_class(nlp_config["lang"])
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/util.py", line 246, in get_lang_class
raise ImportError(Errors.E048.format(lang=lang, err=err)) from err
ImportError: [E048] Can't import language custom_en from spacy.lang: No module named 'spacy.lang.custom_en'
How can I solve this issue?
See the sidebar on the right in this section: https://spacy.io/usage/linguistic-features#language-subclass
python -m spacy train config.cfg --code code.py
I am playing around with flask and connexion to set-up a REST API access for my application.
Scenario #1:
If I launch my app through Pycharm run/debug tool Everything works fine (flask app runs including the API from my agreement_api/openapi/specification.yaml file).
Scenario #2:
But executing python agreement_api/app.py (the main script which contains the app instance) through terminal gives me an error while binding the specification.yaml API with my flask app:
AttributeError: module 'agreement_api.controllers.agreement_controller' has no attribute 'read_agreements'
Clearly the above error message tells me that the method "read_agreeements" doesn't exist but believe me it does (because Scenario #1 is working fine and there are no typos, etc)
My directory structure is as follows:
Project
agreement_api
controllers
agreement_controller.py
models
openapi
specification.yaml
app.py
Dockerfile
Pipfile
License
...
agreement_controller.py
....
def read_agreements():
agreements = Agreement.query.order_by(Agreement.agreement_status).all()
agreement_schema = AgreementSchema(many=True)
return agreement_schema.dump(agreements), 200
....
specification.yaml
servers:
- url: /api
paths:
/agreement:
get:
tags:
- Agreement
summary: Read the list of agreements
description: Read the list of agreements
x-openapi-router-controller: agreement_api.controllers.agreement_controller
operationId: read_agreements
app.py
# Get the application instance
_, connexion_app = create_app()
app = connexion_app.app # Flask instance initialized by Connexion
DB = SQLAlchemy(app)
DB.create_all()
MA = Marshmallow(app)
connexion_app.add_api("specification.yaml")
(Same is the issue when running flask app in Docker container.)
Is there an issue with my directory structure or I'm missing something other?
I didn't post many questions before (should be visible by my poor elaboration/explanation/style so feel free to ask me any detail if required )
if anyone is interested in error stack trace:
Failed to add operation for GET /api/agreement
Failed to add operation for GET /api/agreement
Traceback (most recent call last):
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 209, in add_paths
self.add_operation(path, method)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 173, in add_operation
pass_context_arg_name=self.pass_context_arg_name
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/operations/__init__.py", line 8, in make_operation
return spec.operation_cls.from_spec(spec, *args, **kwargs)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/operations/openapi.py", line 138, in from_spec
**kwargs
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/operations/openapi.py", line 89, in __init__
pass_context_arg_name=pass_context_arg_name
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/operations/abstract.py", line 96, in __init__
self._resolution = resolver.resolve(self)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/resolver.py", line 40, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/resolver.py", line 66, in resolve_function_from_operation_id
raise ResolverError(str(e), sys.exc_info())
connexion.exceptions.ResolverError: <ResolverError: module 'agreement_api.controllers.agreement_controller' has no attribute 'read_agreements'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "agreement_api/app.py", line 62, in <module>
validator_map={"body": RequestBodyValidator},
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 57, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apps/abstract.py", line 156, in add_api
options=api_options.as_dict())
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 111, in __init__
self.add_paths()
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 216, in add_paths
self._handle_add_operation_error(path, method, err.exc_info)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 231, in _handle_add_operation_error
raise value.with_traceback(traceback)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/resolver.py", line 61, in resolve_function_from_operation_id
return self.function_resolver(operation_id)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/utils.py", line 111, in get_function_from_name
module = importlib.import_module(module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/abdullah/Documents/projects/mine/user_agreement_flask_api/agreement_api/controllers/agreement_controller.py", line 3, in <module>
from agreement_api.app import DB
File "/home/abdullah/Documents/projects/mine/user_agreement_flask_api/agreement_api/app.py", line 62, in <module>
validator_map={"body": RequestBodyValidator},
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 57, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apps/abstract.py", line 156, in add_api
options=api_options.as_dict())
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 111, in __init__
self.add_paths()
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 216, in add_paths
self._handle_add_operation_error(path, method, err.exc_info)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/apis/abstract.py", line 231, in _handle_add_operation_error
raise value.with_traceback(traceback)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/resolver.py", line 61, in resolve_function_from_operation_id
return self.function_resolver(operation_id)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/utils.py", line 120, in get_function_from_name
function = deep_getattr(module, attr_path)
File "/home/abdullah/.local/share/virtualenvs/user_agreement_flask_api-7tGsycJK/lib/python3.6/site-packages/connexion/utils.py", line 68, in deep_getattr
return functools.reduce(getattr, attrs, obj)
AttributeError: module 'agreement_api.controllers.agreement_controller' has no attribute 'read_agreements'
Got the solution by my self...
Actually I just have to execute the correct command as mentioned here...
i.e instead of executing python app.py, I have to run flask run and my problem was solved.
when I migrate my database, i see that error.
i did init. (python manager.py db init)
and. migrate (python manager.py db migrate)
i use google app engine, flask, mac, python
what should i do?
$ python manager.py db migrate
/Library/Python/2.7/site-packages/flask_sqlalchemy/__init__.py:839: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
Traceback (most recent call last):
File "manager.py", line 3, in <module>
manager.run()
File "/Library/Python/2.7/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/Library/Python/2.7/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/Library/Python/2.7/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/Library/Python/2.7/site-packages/flask_migrate/__init__.py", line 182, in migrate
version_path=version_path, rev_id=rev_id)
File "/Library/Python/2.7/site-packages/alembic/command.py", line 176, in revision
script_directory.run_env()
File "/Library/Python/2.7/site-packages/alembic/script/base.py", line 421, in run_env
util.load_python_file(self.dir, 'env.py')
File "/Library/Python/2.7/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "/Library/Python/2.7/site-packages/alembic/util/compat.py", line 75, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "migrations/env.py", line 87, in <module>
run_migrations_online()
File "migrations/env.py", line 70, in run_migrations_online
poolclass=pool.NullPool)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/__init__.py", line 428, in engine_from_config
return create_engine(url, **options)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/strategies.py", line 80, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/Library/Python/2.7/site-packages/sqlalchemy/dialects/mysql/gaerdbms.py", line 68, in dbapi
from google.appengine.api import apiproxy_stub_map
ImportError: No module named google.appengine.api
As the Error was suggesting, your runtime environment couldn't find the module. Either install it in your virtualenvironment or globally by following the instruction:
https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python