Configuration
I am using Anaconda to manage my Python environments.
Conda version: 22.9.0
Platform: linux-64 (debian 11 “bullseye”)
Python version: 3.8
Installation
conda create --name prefect-env-3_8 python=3.8
conda activate prefect-env-3_8
conda install -c conda-forge prefect
Verification
prefect version
Version: 2.6.3
API version: 0.8.2
Python version: 3.8.13
Git commit: 9e7da96e
Built: Tue, Oct 18, 2022 1:55 PM
OS/Arch: linux/x86_64
Profile: default
Server type: <client error>
Here we already have something different than what we’re expecting by following the Installation Guide
Error
When trying to activate Orion:
prefect orion start
Error: sqlite3.OperationalError: table flow already exists
___ ___ ___ ___ ___ ___ _____ ___ ___ ___ ___ _ _
| _ \ _ \ __| __| __/ __|_ _| / _ \| _ \_ _/ _ \| \| |
| _/ / _|| _|| _| (__ | | | (_) | /| | (_) | .` |
|_| |_|_\___|_| |___\___| |_| \___/|_|_\___\___/|_|\_|
Configure Prefect to communicate with the server with:
prefect config set PREFECT_API_URL=http://127.0.0.1:4200/api
View the API reference documentation at http://127.0.0.1:4200/docs
Check out the dashboard at http://127.0.0.1:4200
INFO: Started server process [8025]
INFO: Waiting for application startup.
ERROR: Traceback (most recent call last):
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
self.dialect.do_execute(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 108, in execute
self._adapt_connection._handle_exception(error)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 236, in _handle_exception
raise error
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 90, in execute
self.await_(_cursor.execute(operation, parameters))
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
return current.driver.switch(awaitable)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
value = await result
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/cursor.py", line 31, in _execute
return await self._conn._execute(fn, *args, **kwargs)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/core.py", line 129, in _execute
return await future
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/core.py", line 102, in run
result = function()
sqlite3.OperationalError: table flow already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/starlette/routing.py", line 645, in lifespan
async with self.lifespan_context(app):
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/starlette/routing.py", line 540, in __aenter__
await self._router.startup()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/starlette/routing.py", line 622, in startup
await handler()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/api/server.py", line 341, in run_migrations
await db.create_db()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/database/interface.py", line 55, in create_db
await self.run_migrations_upgrade()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/database/interface.py", line 63, in run_migrations_upgrade
await run_sync_in_worker_thread(alembic_upgrade)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 68, in run_sync_in_worker_thread
return await anyio.to_thread.run_sync(call, cancellable=True)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/database/alembic_commands.py", line 29, in alembic_upgrade
alembic.command.upgrade(alembic_config(), revision, sql=dry_run)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/command.py", line 322, in upgrade
script.run_env()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/script/base.py", line 569, in run_env
util.load_python_file(self.dir, "env.py")
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
module = load_module_py(module_id, path)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/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 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/database/migrations/env.py", line 147, in <module>
apply_migrations()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 197, in coroutine_wrapper
return run_async_from_worker_thread(async_fn, *args, **kwargs)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 148, in run_async_from_worker_thread
return anyio.from_thread.run(call)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/anyio/from_thread.py", line 49, in run
return asynclib.run_async_from_thread(func, *args)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 970, in run_async_from_thread
return f.result()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/concurrent/futures/_base.py", line 444, in result
return self.__get_result()
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/database/migrations/env.py", line 141, in apply_migrations
await connection.run_sync(do_run_migrations)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/engine.py", line 548, in run_sync
return await greenlet_spawn(fn, conn, *arg, **kw)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 128, in greenlet_spawn
result = context.switch(value)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/database/migrations/env.py", line 129, in do_run_migrations
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/runtime/environment.py", line 853, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/runtime/migration.py", line 623, in run_migrations
step.migration_fn(**kw)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/prefect/orion/database/migrations/versions/sqlite/2022_01_20_115236_9725c1cbee35_initial_migration.py", line 37, in upgrade
op.create_table(
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/operations/ops.py", line 1254, in create_table
return operations.invoke(op)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/operations/base.py", line 399, in invoke
return fn(self, operation)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/operations/toimpl.py", line 114, in create_table
operations.impl.create_table(table)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/ddl/impl.py", line 354, in create_table
self._exec(schema.CreateTable(table))
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/alembic/ddl/impl.py", line 195, in _exec
return conn.execute(construct, multiparams)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/future/engine.py", line 280, in execute
return self._execute_20(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
return connection._execute_ddl(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl
ret = self._execute_context(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
self._handle_dbapi_exception(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
util.raise_(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
raise exception
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
self.dialect.do_execute(
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 108, in execute
self._adapt_connection._handle_exception(error)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 236, in _handle_exception
raise error
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 90, in execute
self.await_(_cursor.execute(operation, parameters))
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
return current.driver.switch(awaitable)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
value = await result
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/cursor.py", line 31, in _execute
return await self._conn._execute(fn, *args, **kwargs)
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/core.py", line 129, in _execute
return await future
File "/home/gregoirepelegrinadmin/anaconda3/envs/prefect-env/lib/python3.8/site-packages/aiosqlite/core.py", line 102, in run
result = function()
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table flow already exists
[SQL:
CREATE TABLE flow (
id CHAR(36) DEFAULT (
(
lower(hex(randomblob(4)))
|| '-'
|| lower(hex(randomblob(2)))
|| '-4'
|| substr(lower(hex(randomblob(2))),2)
|| '-'
|| substr('89ab',abs(random()) % 4 + 1, 1)
|| substr(lower(hex(randomblob(2))),2)
|| '-'
|| lower(hex(randomblob(6)))
)
) NOT NULL,
created DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f000', 'now')) NOT NULL,
updated DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f000', 'now')) NOT NULL,
name VARCHAR NOT NULL,
tags JSON DEFAULT '[]' NOT NULL,
CONSTRAINT pk_flow PRIMARY KEY (id),
CONSTRAINT uq_flow__name UNIQUE (name)
)
]
(Background on this error at: https://sqlalche.me/e/14/e3q8)
ERROR: Application startup failed. Exiting.
Orion stopped!
This error was already mentioned in this post, but the answer hasn’t been helpful to me. Thanks to everyone who will read this post!
Edit
I’ve just checked the prefect package version which is version 2.6.3