typer helloworld.main run raises ModuleNotFoundError, but py -m typer helloworld.main run works
#1253
Unanswered
martyszewski
asked this question in
Questions
Replies: 1 comment
-
|
Works well on Ubuntu. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Hi! I have a minimal setup:
In
main.pyI define a simple Typer app: (see example code)I activate the virtual environment and install typer. Then:
py -m helloworld.mainworkstyper helloworld.main runfails withModuleNotFoundError: No module named 'helloworld'typer helloworld\main.py runworkspy -m typer helloworld.main runworksIt seems the
typerCLI is executed from.venv/Scripts, so the project root isn’t onsys.path.Launching with
python -m typer helloworld.main runorPYTHONPATH=. typer …fixes it.Is this the intended behaviour? Would it make sense for the
typerlauncher to prepend the CWD tosys.path(mirroringpython -m), or should the docs recommend usingpython -m typerduring local development?I’ve read the docs at https://typer.tiangolo.com/tutorial/typer-command/#run-a-package-or-module and expected
typer helloworld.main runto work too.Is this a misunderstanding on my side about how typer resolves modules, or is there an import context difference between typer and python -m?
Thanks in advance for clarifying!
Operating System
Windows
Operating System Details
Guest OS: Windows 11 — clean installation, no third-party tweaks
Python: CPython 3.13.5 (64-bit) — installed from the official python.org installer, added to
PATHExtra tooling:
pip25.x (bundled), Typer 0.16.x, Rich 14.x — installed in an isolated virtual-env (python -m venv .venv)Typer Version
0.16.0
Python Version
3.13.5
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions