Alembic migrations when some tables exists - python-3.x

I have some migrations in alembic, and try to run alembic upgrade head to up-to-date my DB for revision, but in some cases I have tables, which already exists, so I have an error:
alembic upgrade head
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 3137cf88d8c6, create tables
Traceback (most recent call last):
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
context)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
cursor.execute(statement, parameters)
psycopg2.ProgrammingError: relation "City" already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/toweya/.virtualenvs/numus3/bin/alembic", line 11, in <module>
sys.exit(main())
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/config.py", line 479, in main
CommandLine(prog=prog).main(argv=argv)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/config.py", line 473, in main
self.run_cmd(cfg, options)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/config.py", line 456, in run_cmd
**dict((k, getattr(options, k, None)) for k in kwarg)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/script/base.py", line 416, in run_env
util.load_python_file(self.dir, 'env.py')
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/util/compat.py", line 64, in load_module_py
module_id, path).load_module(module_id)
File "<frozen importlib._bootstrap_external>", line 388, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 809, in load_module
File "<frozen importlib._bootstrap_external>", line 668, in load_module
File "<frozen importlib._bootstrap>", line 268, in _load_module_shim
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "numus/env.py", line 68, in <module>
run_migrations_online()
File "numus/env.py", line 63, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/runtime/environment.py", line 817, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/runtime/migration.py", line 323, in run_migrations
step.migration_fn(**kw)
File "/home/toweya/PycharmProjects/NumusPortal/portal/db_manage/numus/versions/3137cf88d8c6_create_tables.py", line 30, in upgrade
sa.Column('name', sa.String(64), nullable=False),
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/operations/ops.py", line 1106, in create_table
return operations.invoke(op)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/operations/toimpl.py", line 101, in create_table
operations.impl.create_table(table)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/ddl/impl.py", line 194, in create_table
self._exec(schema.CreateTable(table))
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 945, in execute
return meth(self, multiparams, params)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1002, in _execute_ddl
compiled
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
context)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1393, in _handle_dbapi_exception
exc_info
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
raise value.with_traceback(tb)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
context)
File "/home/toweya/.virtualenvs/numus3/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "City" already exists
[SQL: '\nCREATE TABLE "City" (\n\tid SERIAL NOT NULL, \n\tgeoid INTEGER NOT NULL, \n\tname VARCHAR(64) NOT NULL, \n\tPRIMARY KEY (id), \n\tUNIQUE (geoid)\n)\n\n']
How can I ignore existing tables?
That means something like: if table exist - continue but not abort

You need to go to your migration/version folder or alembic :
/path/to/prooject/alembic/versions/3137cf88d8c6.py
and edit the last migration script by removing the script for creating the table in the upgrade function and remove the reverse task in downgrade function in the same script.
As said in flask migrate :
The migration script needs to be reviewed and edited
And I quote this from alembic:
We review and modify these by hand as needed, then proceed normally.
Edit :
You can also do that automatically by using the include_object as suggested by this answer

Related

ModuleNotFoundError: No module named 'users' from dj-rest-auth

I am trying to run celery on a Django application that has dj-rest-auth already configured but, I get the following error when I run - "celery -A config worker -l info" but, it works perfectly fine without errors when I do "python manage.py runserver".
The application has several apps under the folder /apps and within the settings.py, it is imported as "apps.<app_name>". It does have an app called "users" so, it's imported as "apps.users".
Traceback (most recent call last):
File "/usr/local/bin/celery", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/celery/__main__.py", line 15, in main
sys.exit(_main())
File "/usr/local/lib/python3.10/site-packages/celery/bin/celery.py", line 213, in main
return celery(auto_envvar_prefix="CELERY")
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/base.py", line 134, in caller
return f(ctx, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/worker.py", line 343, in worker
worker = app.Worker(
File "/usr/local/lib/python3.10/site-packages/celery/worker/worker.py", line 94, in __init__
self.app.loader.init_worker()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 111, in init_worker
self.import_default_modules()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 105, in import_default_modules
raise response
File "/usr/local/lib/python3.10/site-packages/celery/utils/dispatch/signal.py", line 276, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 82, in on_import_modules
self.worker_fixup.validate_models()
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 121, in validate_models
run_checks()
File "/usr/local/lib/python3.10/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/app/config/urls.py", line 13, in <module>
path("api/v1/auth/", include("dj_rest_auth.urls")),
File "/usr/local/lib/python3.10/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/urls.py", line 4, in <module>
from dj_rest_auth.views import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/views.py", line 16, in <module>
from .app_settings import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/app_settings.py", line 35, in <module>
UserDetailsSerializer = import_callable(serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer))
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/utils.py", line 12, in import_callable
return getattr(import_module(package), attr)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'users'
root#1a45d3d56ced:/app# celery -A config worker -l info
DEBUG 2021-12-09 11:36:44,651 base 132 140186677212992 Configuring Raven for host: None
INFO 2021-12-09 11:36:44,652 base 132 140186677212992 Raven is not configured (logging is disabled). Please see the documentation for more information.
Traceback (most recent call last):
File "/usr/local/bin/celery", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/celery/__main__.py", line 15, in main
sys.exit(_main())
File "/usr/local/lib/python3.10/site-packages/celery/bin/celery.py", line 213, in main
return celery(auto_envvar_prefix="CELERY")
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/base.py", line 134, in caller
return f(ctx, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/bin/worker.py", line 343, in worker
worker = app.Worker(
File "/usr/local/lib/python3.10/site-packages/celery/worker/worker.py", line 94, in __init__
self.app.loader.init_worker()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 111, in init_worker
self.import_default_modules()
File "/usr/local/lib/python3.10/site-packages/celery/loaders/base.py", line 105, in import_default_modules
raise response
File "/usr/local/lib/python3.10/site-packages/celery/utils/dispatch/signal.py", line 276, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 82, in on_import_modules
self.worker_fixup.validate_models()
File "/usr/local/lib/python3.10/site-packages/celery/fixups/django.py", line 121, in validate_models
run_checks()
File "/usr/local/lib/python3.10/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/app/config/urls.py", line 13, in <module>
path("api/v1/auth/", include("dj_rest_auth.urls")),
File "/usr/local/lib/python3.10/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/urls.py", line 4, in <module>
from dj_rest_auth.views import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/views.py", line 16, in <module>
from .app_settings import (
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/app_settings.py", line 35, in <module>
UserDetailsSerializer = import_callable(serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer))
File "/usr/local/lib/python3.10/site-packages/dj_rest_auth/utils.py", line 12, in import_callable
return getattr(import_module(package), attr)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'users'
We faced the same problem. The imports in this case include the module specification strings from settings.py, not just the import statements at the top of the modules. In our case this was the fix
REST_AUTH_SERIALIZERS = {
- "LOGIN_SERIALIZER": "users.api.serializers.LoginSerializer",
+ "LOGIN_SERIALIZER": "<app_name>.users.api.serializers.LoginSerializer",
}

flask db migrate is throwing "AttributeError: can't set attribute" [duplicate]

This question already has answers here:
AttributeError: can't set attribute when connecting to sqlite database with flask-sqlalchemy
(6 answers)
Closed 1 year ago.
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
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.

OSError: libgdal.so.27: cannot open shared object file: No such file or directory

I built a docker file that installs gdal and proj library on CentOS8.
After successfully installation of all dependencies, when i run my docker image i get OSError: libgdal.so.27: cannot open shared object file: No such file or directory.
Please how do i rectify this ?
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/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/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 122, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/options.py", line 206, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 214, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 6, in <module>
from .features import DatabaseFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
from django.contrib.gis.db import models
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module>
import django.contrib.gis.db.models.functions # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
from django.contrib.gis import forms, gdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
from .fields import ( # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
from django.contrib.gis.gdal import GDALException
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/datasource.py", line 39, in <module>
from django.contrib.gis.gdal.driver import Driver
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 50, in <module>
lgdal = CDLL(lib_path)
File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libgdal.so.27: cannot open shared object file: No such file or directory
What i've tried
DISCLAIMER: I really do not understand why i did all of these and i don't know what they mean. I just want to install gdal for geodjango
RUN echo /usr/local/lib >> /etc/ld.so.conf.d/usrlocal.conf
RUN touch /etc/ld.so.conf.d/libgdal-x86_64.conf
RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/libgdal-x86_64.conf
Django recommends doing this
RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

ModuleNotFoundError in django when adding app

Django can't find my app and it shows me "ModuleNotFoundError" when I try to run server my web
this is my setting.py :
INSTALLED_APPS = [
......
'djmoney',
'transition', --> this is my app
]
and this is the complete error :
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/usr/local/lib/python3.8/dist-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.8/dist-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.8/dist-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/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 'transition'
A possible reason for this error is your project directory structure. If this is indeed the case, you should change it to xxx.transition, where xxx = the name of your project.

Face many issues to rasa initialization rasa init --no-prompt

I knew, its duplicate question, but I can't find the way to solve my issue.
I tried, tensorflow all versions.
Python 3.6.8
tensorflow = 1.15.0
Windows 10
Faced VC++ error, I installed VC++ 14
I tried via using condo, still facing the tensorflow issue.
I face the issue like, its created the project structure, but tensorflow.python.framework.errors
To get started quickly, an initial project will be created.
If you need some help, check out the documentation at https://rasa.com/docs/rasa.
Created project directory at 'C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Scripts\venv\Scripts'.
Finished creating project structure.
Training an initial model...
Training Core model...
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Scripts\venv\Scripts\rasa.exe\__main__.py", line 7, in <module>
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\__main__.py", line 92, in main
cmdline_arguments.func(cmdline_arguments)
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\cli\scaffold.py", line 206, in run
init_project(args, path)
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\cli\scaffold.py", line 118, in init_project
print_train_or_instructions(args, path)
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\cli\scaffold.py", line 58, in print_train_or_instructions
args.model = rasa.train(domain, config, training_files, output)
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\train.py", line 50, in train
additional_arguments=additional_arguments,
File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 583, in run_until_complete
return future.result()
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\train.py", line 101, in train_async
additional_arguments,
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\train.py", line 188, in _train_async_internal
additional_arguments=additional_arguments,
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\train.py", line 223, in _do_training
additional_arguments=additional_arguments,
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\train.py", line 361, in _train_core_with_validated_data
additional_arguments=additional_arguments,
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\core\train.py", line 43, in train
policies = config.load(policy_config)
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\core\config.py", line 28, in load
return PolicyEnsemble.from_dict(config_data)
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\core\policies\ensemble.py", line 308, in from_dict
constr_func = registry.policy_from_module_path(policy_name)
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\core\registry.py", line 21, in policy_from_module_path
module_path, lookup_path="rasa.core.policies.registry"
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\utils\common.py", line 220, in class_from_module_path
m = importlib.import_module(lookup_path)
File "C:\ProgramData\Anaconda3\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 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\core\policies\registry.py", line 5, in <module>
from rasa.core.policies.ted_policy import TEDPolicy
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\rasa\core\policies\ted_policy.py", line 8, in <module>
import tensorflow_addons as tfa
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\tensorflow_addons\__init__.py", line 21, in <module>
from tensorflow_addons import activations
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\tensorflow_addons\activations\__init__.py", line 21, in <module>
from tensorflow_addons.activations.gelu import gelu
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\tensorflow_addons\activations\gelu.py", line 24, in <module>
get_path_to_datafile("custom_ops/activations/_activation_ops.so"))
File "c:\users\administrator\appdata\local\programs\python\python36\scripts\venv\lib\site-packages\tensorflow_core\python\framework\load_library.py", line 61, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid name: Addons>Gelu (Did you use CamelCase?); in OpDef: name: "Addons>Gelu" input_arg { name: "features" type_attr: "T" } output_arg { name: "activations" type_attr: "T" } attr { name: "T" type: "type" allowed_values { list { type: DT_HALF type: DT_FLOAT type: DT_DOUBLE } } } attr { name: "approximate" type: "bool" default_value { b: true } }```
rasa>=1.8 supports tensorflow 2 and tensorflow-text. However, tensorflow-text is not supported on Windows, which it looks like you're developing on. You can still use Rasa, but some pipelines will not be supported. I'd recommend this video tutorial for installing Rasa on Windows: https://www.youtube.com/watch?v=4ewIABo0OkU&t=1s

Resources