Installation Error - prefect version cmd errors

New to Prefect : using this information as guidelines : Installation - Prefect Docs

I am receiving following 2 errors - its a common package error - what am i missing ?

my Python version : 3.10.8
As per Using importlib.metadata — Python 3.11.2 documentation Changed in version 3.10: importlib.metadata is no longer provisional.

------------- Error 1 -------------
PS C:\0-mywfh\Python\pythonTutorial\prefect> prefect version
Traceback (most recent call last):
File “C:\Python310\Scripts\prefect-script.py”, line 33, in
sys.exit(load_entry_point(‘prefect’, ‘console_scripts’, ‘prefect’)())
File “C:\Python310\Scripts\prefect-script.py”, line 22, in importlib_load_entry_point
for entry_point in distribution(dist_name).entry_points
File “C:\Python310\lib\importlib\metadata_init_.py”, line 957, in distribution
return Distribution.from_name(distribution_name)
File “C:\Python310\lib\importlib\metadata_init_.py”, line 548, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for prefect

------------- Error 2 -------------
PS C:\0-mywfh\Python\pythonTutorial\prefect> prefect orion start
Traceback (most recent call last):
File “C:\Python310\Scripts\prefect-script.py”, line 33, in
sys.exit(load_entry_point(‘prefect’, ‘console_scripts’, ‘prefect’)())
File “C:\Python310\Scripts\prefect-script.py”, line 22, in importlib_load_entry_point
for entry_point in distribution(dist_name).entry_points
File “C:\Python310\lib\importlib\metadata_init_.py”, line 957, in distribution
return Distribution.from_name(distribution_name)
File “C:\Python310\lib\importlib\metadata_init_.py”, line 548, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for prefect
PS C:\0-mywfh\Python\pythonTutorial\prefect>

1 Like

Can you try it in Conda virtual environment?

love your username! :smile:

Anna,

Within Conda, Orion is not starting ? it picks up Python 3.10 and not conda python 3.9 ???

----------------- Error -------------------------------------
(base) C:\Users\Shail>conda -V
conda 22.9.0

(base) C:\Users\Shail>prefect --version
2.6.4

(base) C:\Users\Shail>prefect orion start


| _ \ _ \ | | / | | / _ | _ _ / _ | | |
| / / || || | ( | | | () | /| | () | .` |
|
| |
|__
|| |
_
| |_| _
/||___/|_|_|

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 [15040]
INFO: Waiting for application startup.
ERROR: Traceback (most recent call last):
File “C:\Python310\lib\site-packages\alembic\script\base.py”, line 233, in _catch_revision_errors
yield
File “C:\Python310\lib\site-packages\alembic\script\base.py”, line 443, in upgrade_revs
for script in reversed(list(revs))
File “C:\Python310\lib\site-packages\alembic\script\revision.py”, line 799, in iterate_revisions
revisions, heads = fn(
File “C:\Python310\lib\site-packages\alembic\script\revision.py”, line 1454, in collect_upgrade_revisions
current_revisions = self.get_revisions(lower)
File “C:\Python310\lib\site-packages\alembic\script\revision.py”, line 527, in get_revisions
return sum([self.get_revisions(id_elem) for id_elem in id
], ())
File “C:\Python310\lib\site-packages\alembic\script\revision.py”, line 527, in
return sum([self.get_revisions(id_elem) for id_elem in id
], ())
File “C:\Python310\lib\site-packages\alembic\script\revision.py”, line 552, in get_revisions
return tuple(
File “C:\Python310\lib\site-packages\alembic\script\revision.py”, line 553, in
self._revision_for_ident(rev_id, branch_label)
File “C:\Python310\lib\site-packages\alembic\script\revision.py”, line 624, in _revision_for_ident
raise ResolutionError(
alembic.script.revision.ResolutionError: No such revision or branch ‘3ced59d8806b’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “C:\Python310\lib\site-packages\starlette\routing.py”, line 645, in lifespan
async with self.lifespan_context(app):
File “C:\Python310\lib\site-packages\starlette\routing.py”, line 540, in aenter
await self._router.startup()
File “C:\Python310\lib\site-packages\starlette\routing.py”, line 622, in startup
await handler()
File “C:\Python310\lib\site-packages\prefect\orion\api\server.py”, line 341, in run_migrations
await db.create_db()
File “C:\Python310\lib\site-packages\prefect\orion\database\interface.py”, line 55, in create_db
await self.run_migrations_upgrade()
File “C:\Python310\lib\site-packages\prefect\orion\database\interface.py”, line 63, in run_migrations_upgrade
await run_sync_in_worker_thread(alembic_upgrade)
File “C:\Python310\lib\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 “C:\Python310\lib\site-packages\anyio\to_thread.py”, line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File “C:\Python310\lib\site-packages\anyio_backends_asyncio.py”, line 937, in run_sync_in_worker_thread
return await future
File “C:\Python310\lib\site-packages\anyio_backends_asyncio.py”, line 867, in run
result = context.run(func, *args)
File “C:\Python310\lib\site-packages\prefect\orion\database\alembic_commands.py”, line 29, in alembic_upgrade
alembic.command.upgrade(alembic_config(), revision, sql=dry_run)
File “C:\Python310\lib\site-packages\alembic\command.py”, line 322, in upgrade
script.run_env()
File “C:\Python310\lib\site-packages\alembic\script\base.py”, line 569, in run_env
util.load_python_file(self.dir, “env.py”)
File “C:\Python310\lib\site-packages\alembic\util\pyfiles.py”, line 94, in load_python_file
module = load_module_py(module_id, path)
File “C:\Python310\lib\site-packages\alembic\util\pyfiles.py”, line 110, in load_module_py
spec.loader.exec_module(module) # type: ignore
File “”, line 883, in exec_module
File “”, line 241, in _call_with_frames_removed
File “C:\Python310\lib\site-packages\prefect\orion\database\migrations\env.py”, line 147, in
apply_migrations()
File “C:\Python310\lib\site-packages\prefect\utilities\asyncutils.py”, line 197, in coroutine_wrapper
return run_async_from_worker_thread(async_fn, *args, **kwargs)
File “C:\Python310\lib\site-packages\prefect\utilities\asyncutils.py”, line 148, in run_async_from_worker_thread
return anyio.from_thread.run(call)
File “C:\Python310\lib\site-packages\anyio\from_thread.py”, line 49, in run
return asynclib.run_async_from_thread(func, *args)
File “C:\Python310\lib\site-packages\anyio_backends_asyncio.py”, line 970, in run_async_from_thread
return f.result()
File “C:\Python310\lib\concurrent\futures_base.py”, line 458, in result
return self.__get_result()
File “C:\Python310\lib\concurrent\futures_base.py”, line 403, in __get_result
raise self._exception
File “C:\Python310\lib\site-packages\prefect\orion\database\migrations\env.py”, line 141, in apply_migrations
await connection.run_sync(do_run_migrations)
File “C:\Python310\lib\site-packages\sqlalchemy\ext\asyncio\engine.py”, line 548, in run_sync
return await greenlet_spawn(fn, conn, *arg, **kw)
File “C:\Python310\lib\site-packages\sqlalchemy\util_concurrency_py3k.py”, line 128, in greenlet_spawn
result = context.switch(value)
File “C:\Python310\lib\site-packages\prefect\orion\database\migrations\env.py”, line 129, in do_run_migrations
context.run_migrations()
File “”, line 8, in run_migrations
File “C:\Python310\lib\site-packages\alembic\runtime\environment.py”, line 853, in run_migrations
self.get_context().run_migrations(**kw)
File “C:\Python310\lib\site-packages\alembic\runtime\migration.py”, line 611, in run_migrations
for step in self._migrations_fn(heads, self):
File “C:\Python310\lib\site-packages\alembic\command.py”, line 311, in upgrade
return script._upgrade_revs(revision, rev)
File “C:\Python310\lib\site-packages\alembic\script\base.py”, line 431, in _upgrade_revs
with self._catch_revision_errors(
File “C:\Python310\lib\contextlib.py”, line 153, in exit
self.gen.throw(typ, value, traceback)
File “C:\Python310\lib\site-packages\alembic\script\base.py”, line 265, in _catch_revision_errors
raise util.CommandError(resolution) from re
alembic.util.exc.CommandError: Can’t locate revision identified by ‘3ced59d8806b’

ERROR: Application startup failed. Exiting.
Orion stopped!

(base) C:\Users\Shail>

you would need to first create a new custom virtual environment and activate it, based on this, it looks like you are in a base environment

try:

conda create -y --name prefect python=3.9        
conda activate prefect
pip install prefect
prefect orion start

Anna,

creating new virtual env also ran into different errors while starting Orion

----------- Error --------------------

(prefect) C:\Users\Shail>prefect --version
2.6.4

(prefect) C:\Users\Shail>prefect orion start


| _ \ _ \ | | / | | / _ | _ _ / _ | | |
| / / || || | ( | | | () | /| | () | .` |
|
| |
|__
|| |
_
| |_| _
/||___/|_|_|

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 [14228]
INFO: Waiting for application startup.
ERROR: Traceback (most recent call last):
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\base.py”, line 233, in _catch_revision_errors
yield
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\base.py”, line 443, in upgrade_revs
for script in reversed(list(revs))
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\revision.py”, line 799, in iterate_revisions
revisions, heads = fn(
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\revision.py”, line 1454, in collect_upgrade_revisions
current_revisions = self.get_revisions(lower)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\revision.py”, line 527, in get_revisions
return sum([self.get_revisions(id_elem) for id_elem in id
], ())
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\revision.py”, line 527, in
return sum([self.get_revisions(id_elem) for id_elem in id
], ())
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\revision.py”, line 552, in get_revisions
return tuple(
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\revision.py”, line 553, in
self._revision_for_ident(rev_id, branch_label)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\revision.py”, line 624, in _revision_for_ident
raise ResolutionError(
alembic.script.revision.ResolutionError: No such revision or branch ‘3ced59d8806b’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “C:\Anaconda3\envs\prefect\lib\site-packages\starlette\routing.py”, line 645, in lifespan
async with self.lifespan_context(app):
File “C:\Anaconda3\envs\prefect\lib\site-packages\starlette\routing.py”, line 540, in aenter
await self._router.startup()
File “C:\Anaconda3\envs\prefect\lib\site-packages\starlette\routing.py”, line 622, in startup
await handler()
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\orion\api\server.py”, line 341, in run_migrations
await db.create_db()
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\orion\database\interface.py”, line 55, in create_db
await self.run_migrations_upgrade()
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\orion\database\interface.py”, line 63, in run_migrations_upgrade
await run_sync_in_worker_thread(alembic_upgrade)
File “C:\Anaconda3\envs\prefect\lib\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 “C:\Anaconda3\envs\prefect\lib\site-packages\anyio\to_thread.py”, line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File “C:\Anaconda3\envs\prefect\lib\site-packages\anyio_backends_asyncio.py”, line 937, in run_sync_in_worker_thread
return await future
File “C:\Anaconda3\envs\prefect\lib\site-packages\anyio_backends_asyncio.py”, line 867, in run
result = context.run(func, *args)
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\orion\database\alembic_commands.py”, line 29, in alembic_upgrade
alembic.command.upgrade(alembic_config(), revision, sql=dry_run)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\command.py”, line 322, in upgrade
script.run_env()
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\base.py”, line 569, in run_env
util.load_python_file(self.dir, “env.py”)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\util\pyfiles.py”, line 94, in load_python_file
module = load_module_py(module_id, path)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\util\pyfiles.py”, line 110, in load_module_py
spec.loader.exec_module(module) # type: ignore
File “”, line 850, in exec_module
File “”, line 228, in _call_with_frames_removed
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\orion\database\migrations\env.py”, line 147, in
apply_migrations()
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\utilities\asyncutils.py”, line 197, in coroutine_wrapper
return run_async_from_worker_thread(async_fn, *args, **kwargs)
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\utilities\asyncutils.py”, line 148, in run_async_from_worker_thread
return anyio.from_thread.run(call)
File “C:\Anaconda3\envs\prefect\lib\site-packages\anyio\from_thread.py”, line 49, in run
return asynclib.run_async_from_thread(func, *args)
File “C:\Anaconda3\envs\prefect\lib\site-packages\anyio_backends_asyncio.py”, line 970, in run_async_from_thread
return f.result()
File “C:\Anaconda3\envs\prefect\lib\concurrent\futures_base.py”, line 446, in result
return self.__get_result()
File “C:\Anaconda3\envs\prefect\lib\concurrent\futures_base.py”, line 391, in __get_result
raise self._exception
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\orion\database\migrations\env.py”, line 141, in apply_migrations
await connection.run_sync(do_run_migrations)
File “C:\Anaconda3\envs\prefect\lib\site-packages\sqlalchemy\ext\asyncio\engine.py”, line 548, in run_sync
return await greenlet_spawn(fn, conn, *arg, **kw)
File “C:\Anaconda3\envs\prefect\lib\site-packages\sqlalchemy\util_concurrency_py3k.py”, line 128, in greenlet_spawn
result = context.switch(value)
File “C:\Anaconda3\envs\prefect\lib\site-packages\prefect\orion\database\migrations\env.py”, line 129, in do_run_migrations
context.run_migrations()
File “”, line 8, in run_migrations
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\runtime\environment.py”, line 853, in run_migrations
self.get_context().run_migrations(**kw)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\runtime\migration.py”, line 611, in run_migrations
for step in self._migrations_fn(heads, self):
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\command.py”, line 311, in upgrade
return script._upgrade_revs(revision, rev)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\base.py”, line 439, in _upgrade_revs
return [
File “C:\Anaconda3\envs\prefect\lib\contextlib.py”, line 137, in exit
self.gen.throw(typ, value, traceback)
File “C:\Anaconda3\envs\prefect\lib\site-packages\alembic\script\base.py”, line 265, in _catch_revision_errors
raise util.CommandError(resolution) from re
alembic.util.exc.CommandError: Can’t locate revision identified by ‘3ced59d8806b’

ERROR: Application startup failed. Exiting.
Orion stopped!

(prefect) C:\Users\Shail>

ok, try this:

rm ~/.prefect/orion.db
prefect orion start
1 Like

Anna,

very well analyzed, Good to close

Thanks
Shaila

1 Like