`ModuleNotFoundError` on `saq` start
See original GitHub issueHello! Thank you for nice framework!
I’m trying to use it, but getting an exception on attempt to start worker:
$ saq app.worker.settings
Traceback (most recent call last):
File "********/saq-test/.venv/bin/saq", line 8, in <module>
sys.exit(main())
File "********/saq-test/.venv/lib/python3.10/site-packages/saq/__main__.py", line
73, in main
start(
File "********/saq-test/.venv/lib/python3.10/site-packages/saq/worker.py", line 2
83, in start
settings = import_settings(settings)
File "********/saq-test/.venv/lib/python3.10/site-packages/saq/worker.py", line 2
78, in import_settings
module = importlib.import_module(module_path)
File "/usr/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 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'app'
Project structure:
├── app
│ ├── __init__.py
│ └── worker.py
├── poetry.lock
└── pyproject.toml
worker.py
contents:
from typing import Any, Dict
from saq import Queue
async def startup(_: Dict[str, Any]) -> None:
print("Hello from startup job!")
settings = {
"queue": Queue.from_url("redis://localhost"),
"functions": [],
"concurrency": 8,
"startup": startup,
}
If I try to use importlib
from interpreter, everything is OK:
>>> import importlib
>>> importlib.import_module("app.worker")
<module 'app.worker' from '********/saq-test/app/worker.py'>
>>> _.settings
{'queue': <saq.queue.Queue object at 0x7f81fcd52740>, 'functions': [], 'concurrency': 8, 'startup': <function startup at 0x7f81fcd681f0>}
>>>
I’ve found, that current directory not in sys.path
and used PYTHONPATH
to this fix the problem:
$ PYTHONPATH="$PYTHONPATH:$PWD" saq app.worker.settings
Hello from startup job!
Could you help me to figure out, is this a bug or my fault?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ModuleNotFoundError: No module named 'django-cms-saq'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-cms-saq' How to remove the Mod.
Read more >ModuleNotFoundError: No module named '__main__.xxxx ...
What's worse, when I opened a Python console, and tried to import the main module manually ( import mypackage.main ), then I got...
Read more >saq - PyPI
SAQ (Simple Async Queue) is a simple and performant job queueing framework built on top of asyncio and redis. It can be used...
Read more >mozilla-central: changeset 560845 ...
Bug 1680802: Bump vendored virtualenv package r=firefox-build-system-reviewers,sheehan,glandium The `wheel` package was failing with Mac Big ...
Read more >Error mongoosemodule unable to connect to the database
How do i start Socket.IO angular 13: Module not found: Error: Can't resolve 'rxjs/operators' Store Winston js log files on GKE npm ERESOLVE ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yea, this is just how python works. you either need to install your app or add it in python path, it’s a bit annoying, but adding some special handling in saq for this sounds a bit dangerous
sure, wanna make a pr?